File manager - Edit - /home/autoph/public_html/projects/Rating-AutoHub/public/css/customer.tar
Back
activity_modal.js 0000644 00000020476 15030155051 0010116 0 ustar 00 (function ($, undefined) { $.fn.getCursorPosition = function () { var el = $(this).get(0); var pos = 0; if ('selectionStart' in el) { pos = el.selectionStart; } else if ('selection' in document) { el.focus(); var Sel = document.selection.createRange(); var SelLength = document.selection.createRange().text.length; Sel.moveStart('character', -el.value.length); pos = Sel.text.length - SelLength; } return pos; } })(jQuery); const $customerActFrm = $('.customer-activity-form'); const $customerInsuranceActFrm = $('.customer-activity-close-deal-form'); function templateEvt() { $customerActFrm.find('.customer-activity-template').each(function () { $(this).on('click', function (e) { var position = $customerActFrm.find("[name=activity]").getCursorPosition() var content = $customerActFrm.find("[name=activity]").val(); var newContent = content.substr(0, position) + $(this).text()+ content.substr(position); $customerActFrm.find("[name=activity]").val(newContent); $customerActFrm.find("[name=activity]").trigger("focus"); }); }); } function closeDealEvt() { $customerActFrm.find('.btn-close-deal').on("click", function (e) { $('#modal-customer-activity').modal('hide'); $('#modal-customer-activity-close-deal').modal('show'); $('#modal-customer-activity-close-deal').off('hidden.bs.modal').on('hidden.bs.modal', function () { $('#modal-customer-activity').modal('show'); }); return false; Swal.fire({ icon: 'question', html: 'Are you sure you want to close the deal?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, showClass: { backdrop: "swal2-noanimation", // disable backdrop animation popup: "", // disable popup animation icon: "", // disable icon animation }, hideClass: { popup: "", // disable popup fade-out animation }, }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "/customer", method: "POST", dataType: 'json', data: { apiKey: '3695340036334748', customer_id: customer_record_id }, beforeSend: function () { sweetAlertSimple('info', 'Oops...', 'Removing customer...') }, success: function (result) { if (parseInt(result.status) === 1) { sweetAlertSimple('success', 'Nice...', result.message); var url = location_url + "customer.php"; window.location.href = url; } else { sweetAlertSimple('error', 'Oops...', result.message) } }, error: function () { sweetAlertSimple('error', 'Oops...', 'Error has been occurred, please try again.') } }); } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }); }); } function activityFrmEvt() { $customerActFrm.on("submit",function (event) { var formData = new FormData(this); formData.append( "csrf_token", $("meta[name='csrf-token']").attr("content") ); formData.append("id", (typeof activity_id === 'undefined') ? "" : activity_id); formData.append("customer_id", (typeof customer_record_id === 'undefined') ? "" : customer_record_id); formData.append("vehicle_id", (typeof vehicle_record_id === 'undefined') ? "" : vehicle_record_id); $.ajax({ url: "/customer/activity/store", // url: url.store, type: "POST", data: formData, // timeout: 9000, processData: false, contentType: false, beforeSend: function () { $customerActFrm.find("button[type=submit]").prop("disabled", true); }, success: function (result) { $customerActFrm.find("button[type=submit]").prop("disabled", false); if (parseInt(result.status) === 1) { sweetAlertSimple('success', '', result.message); $customerActFrm.trigger("reset"); $('#modal-customer-activity').modal('hide'); } else { sweetAlertSimple('error', '', result.message) } }, error: function () { sweetAlertSimple('error', '', 'Error has occured.') $customerActFrm.find("button[type=submit]").prop("disabled", false); }, }); event.preventDefault(); }); } function activityInsuranceFrmEvt() { $customerInsuranceActFrm.on("submit",function (event) { var formData = new FormData(this); formData.append( "csrf_token", $("meta[name='csrf-token']").attr("content") ); formData.append("id", (typeof activity_insurance_id === 'undefined') ? "" : activity_insurance_id); formData.append("customer_id", (typeof customer_record_id === 'undefined') ? "" : customer_record_id); formData.append("vehicle_id", (typeof vehicle_record_id === 'undefined') ? "" : vehicle_record_id); $.ajax({ url: "/customer/activity/insurance/store", // url: url.store, type: "POST", data: formData, // timeout: 9000, processData: false, contentType: false, beforeSend: function () { $customerInsuranceActFrm.find("button[type=submit]").prop("disabled", true); }, success: function (result) { $customerInsuranceActFrm.find("button[type=submit]").prop("disabled", false); if (parseInt(result.status) === 1) { // alert("1") $customerInsuranceActFrm.trigger("reset"); $customerActFrm.trigger("reset"); $('#modal-customer-activity-close-deal').off('hidden.bs.modal'); $('#modal-customer-activity-close-deal').modal('hide'); sweetAlertSimple('success', '', result.message); } else { sweetAlertSimple('error', '', result.message) } }, error: function () { sweetAlertSimple('error', '', 'Error has occured.') $customerInsuranceActFrm.find("button[type=submit]").prop("disabled", false); }, }); event.preventDefault(); }); } function initDateFields() { $(".activity-date").datetimepicker({ format: "L", }); } function refreshTableActivities() { var $table = $('#activity-table') $table.bootstrapTable('destroy').bootstrapTable(); $(function() { $table.bootstrapTable('refresh', { url: 'app/table/customer_activity.php' }); }) } function queryParamsActivities(params) { console.log(params) return { search: params.search, offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, customer_id: ((typeof customer_record_id === 'undefined') ? "" : customer_record_id), vehicle_id: ((typeof vehicle_record_id === 'undefined') ? "" : vehicle_record_id), }; } $(function () { $('#datetimepicker2').datetimepicker({ format: 'DD/MM/YYYY' }); // alert(vehicle_record_id) console.log("ADsada") if (typeof vehicle_record_id !== 'undefined') { if (vehicle_record_id) { // hide vehicle information $customerInsuranceActFrm.find(".activity-vehicle-info").hide(); // $customerInsuranceActFrm.find("[name=conduction_sticker]").hide(); } } initDateFields(); activityFrmEvt(); activityInsuranceFrmEvt(); templateEvt(); closeDealEvt(); }); customer.js 0000644 00000114103 15030155051 0006736 0 ustar 00 var new_customer_is_individual = false; var shown = false; var count_customer_summary = null; var customer_grid = null; var onShowFiltersDialog = function() { if (getCookie("customer_toggle") == null || parseInt($.cookie("customer_toggle")) == 0) { var $table = $('#customer-table'); $table.bootstrapTable('destroy'); initGrid() $.cookie("customer_toggle", 1); } else { // initList() $.cookie("customer_toggle", 0); } refreshTableCustomer() } function buttonsFunction() { return { grid_refresh: { 'icon': 'fa fa-sync', 'event': 'refreshTableCustomer', 'attributes': { 'title': 'Refresh', 'data-test': 'test123' } }, grid_toggle_on: { 'icon': 'fa fa-toggle-on', 'event': 'onShowFiltersDialog', 'attributes': { 'title': 'Toggle List View', 'data-test': 'test123' } }, grid_toggle_off: { 'icon': 'fa fa-toggle-off', 'event': 'onShowFiltersDialog', 'attributes': { 'title': 'Toggle Grid View', 'data-test': 'test123' } } } } function initGrid() { var $table = $('#customer-table'); // $table.bootstrapTable('destroy'); $table.bootstrapTable({ formatSearch: function() { return 'Search Customer' }, }); } function initList() { var $table = $('#customer-table') $table.bootstrapTable('destroy') $table.bootstrapTable({ sidePagination: 'server', formatSearch: function() { return 'Search Customer' }, onSearch: function(text) { $table.addClass('loading'); }, onLoadSuccess: function() { $table.removeClass('loading'); } }); } function customSearch(data, text) { if (getCookie("customer_toggle") != null && $.cookie("customer_toggle") == 1) { refreshTableCustomer(); } return data.filter(function(row) { return row.name.toLowerCase().replace(/\s/g, "").indexOf(text.toLowerCase().replace(/\s/g, "")) > -1 }) } function customerCountSummary() { var dms = ($("#dms").val() == '') ? '0' : $("#dms").val(); var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); var gender = ($("#gender").val() == '') ? 'all' : $("#gender").val(); var type = ($("#type").val() == '') ? '0' : $("#type").val(); var filter_age = ($("#filter-age").val() == '') ? '0' : $("#filter-age").val(); var filter_data = ($("#filter-data").val() == '') ? '0' : $("#filter-data").val(); var customer_actions = ($("#customer-actions").val() == '') ? '0' : $("#customer-actions").val(); var my_records = $('#my_record_filter').is(":checked"); if(count_customer_summary != null){ count_customer_summary.abort(); } count_customer_summary = $.ajax({ url: "api/customer/customerv2.php", type: "POST", dataType: 'json', data: { dms: dms, company: company, type: type, gender: gender, filter_age: filter_age, filter_data: filter_data, apiKey: '8666264351338448', my_records : my_records }, beforeSend: function() {}, success: function(result) { // result.total $('#total_customer_count').text(result.total_count); $('#new_customer_count').text(result.new_customer_count); $('#updated_customer_count').text(result.updated_customer_count); $('#new_today_customer_count').text(result.new_today_customer_count); } }); } function refreshTableCustomer() { if (getCookie("customer_toggle") != null && $.cookie("customer_toggle") == 1) { initGrid() getCustomerGrid(0, 9); showGrid(); } else { initList() var $table = $('#customer-table') // $table.bootstrapTable('destroy') $(function() { $table.bootstrapTable('refresh', { url: 'app/table/bt_customer_list.php' }); }) showList(); } customerCountSummary(); } function gotoOffsetCustomer(n) { // alert(n) // $.cookie("customer_list_offset",n); getCustomerGrid(n, 9); } function getCustomerGrid(offset, limit) { var dms = ($("#dms").val() == '') ? '0' : $("#dms").val(); var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); var gender = ($("#gender").val() == '') ? 'all' : $("#gender").val(); var type = ($("#type").val() == '') ? '0' : $("#type").val(); var filter_age = ($("#filter-age").val() == '') ? '0' : $("#filter-age").val(); var filter_data = ($("#filter-data").val() == '') ? '0' : $("#filter-data").val(); var customer_actions = ($("#customer-actions").val() == '') ? '0' : $("#customer-actions").val(); var search = $(".search-input").val(); var my_records = $('#my_record_filter').is(":checked"); if(customer_grid != null){ customer_grid.abort(); } customer_grid = $.ajax({ url: 'app/table/bt_customer_list.php', type: "POST", dataType: 'json', data: { search: search, grid: 1, offset: offset, limit: limit, dms: dms, company: company, type: type, gender: gender, filter_age: filter_age, filter_data: filter_data, customer_actions: customer_actions, my_records : my_records }, beforeSend: function() { $('#loader-main').show(); }, success: function(result) { // result.total $('#customer-grid-data').html(''); $('#customer-grid-data').append(result.customer_list); $('#customer-grid-data-paging').html(''); // if(result.total <= 0){ // $('#customer-grid-data-paging').append(result.customer_list_paging); // } // if(result.grid_offset > 6){ $('#customer-grid-data-paging').append(result.customer_list_paging); // } $('#loader-main').hide(); } }); } function showGrid() { $("#customer-grid").show(); $("#grid-card").show(); $('#customer-grid-data-paging').show(); $("button[name='grid_toggle_on']").show(); $("#customer-table").hide(); $(".fixed-table-pagination").hide(); $("button[name='grid_toggle_off']").hide(); } function showList() { $("#customer-table").show(); $("#grid-card").hide(); $(".fixed-table-pagination").show(); $("button[name='grid_toggle_off']").show(); $("#customer-grid").hide(); $('#customer-grid-data-paging').hide(); $("button[name='grid_toggle_on']").hide(); } function queryParams(params) { var dms = ($("#dms").val() == '') ? '0' : $("#dms").val(); var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); var gender = ($("#gender").val() == '') ? 'all' : $("#gender").val(); var type = ($("#type").val() == '') ? '0' : $("#type").val(); var filter_age = ($("#filter-age").val() == '') ? '0' : $("#filter-age").val(); var filter_data = ($("#filter-data").val() == '') ? '0' : $("#filter-data").val(); var customer_actions = ($("#customer-actions").val() == '') ? '0' : $("#customer-actions").val(); var my_records = $('#my_record_filter').is(":checked"); var start = $('#filter-date').data('daterangepicker').startDate; var end = $('#filter-date').data('daterangepicker').endDate; var start_date = start.format('YYYY-MM-DD'); var end_date = end.format('YYYY-MM-DD'); return { search: params.search, offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, dms: dms, company: company, type: type, gender: gender, filter_age: filter_age, filter_data: filter_data, customer_actions: customer_actions, my_records : my_records, start_date : start_date, end_date : end_date, }; } // DATE FILTER $('#filter-date').on('apply.daterangepicker', function(ev, picker) { $('#filter-date span').html(picker.startDate.format('MMMM D, YYYY') + ' - ' + picker.endDate .format( 'MMMM D, YYYY')); cb(picker.startDate, picker.endDate); }); function cb(start, end) { var startDate = start.format('YYYY-MM-DD'); passDate(start, end); //pass empty dates } function passDate(startDate, endDate) { var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); filtered_company = (parseInt(company) === 0) ? '' : '&selected_company=' + company; filtered_date_start = (startDate === '') ? '' : '&start_date=' + startDate; filtered_date_end = (endDate === '') ? '' : '&end_date=' + endDate; refreshTableCustomer(); } //END DATE FILTER function customerModal(isIndividual) { new_customer_is_individual = isIndividual; $('#proceed-button').text("Add Customer"); $('.customer-modal-overlay').hide(); if (isIndividual) { $('#modal-title').text("New Customer (Individual)"); checkFieldsModal(true); } else { $('#modal-title').text("New Customer (Corporation)"); checkFieldsModal(false); } resetCustomerModal(); $("#addRowDataSource").click(); } function customerInfo(id) { $.cookie("customer_selected_tab", 'custom-tabs-three-home-tab'); window.location.href = "customer_view.php?q=" + id; } function addFilterListener(){ $('#dms').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#company-filter').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#gender').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#type').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#filter-data').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#filter-age').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); addFilterListenerCustomerAction(); } function addFilterListenerCustomerAction(){ $('#customer-actions').off('change.mychange').on('change.mychange', function() { refreshTableCustomer(); }); } ///////////////////////////////////////////////////////////////////////////////////////////////////// $(document).ready(function() { // if (getCookie("customer_toggle") != null && parseInt($.cookie("customer_toggle")) == 1) { // initGrid() // } else { // initList() // } refreshTableCustomer() addFilterListener(); var $table = $('#customer-table'); $('#customer_action_all').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('all').trigger('change'); }); $('#customer_action_new').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('new').trigger('change'); }); $('#customer_action_updated').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('updated').trigger('change'); }); $('#customer_action_added').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('added').trigger('change'); }); $('#dms').select2({ placeholder: "DMS Type", allowClear: true }) $('#company-filter').select2({ placeholder: "Company", allowClear: true }) $('#gender').select2({ placeholder: "Gender", allowClear: true }) $('#type').select2({ placeholder: "Customer Type", allowClear: true }) $('#filter-age').select2({ placeholder: "Age", allowClear: true }) $('#filter-data').select2({ placeholder: "Data Type", allowClear: true }) $('#customer-actions').select2({ placeholder: "Customer Actions", allowClear: true }) $( "#my_record_filter").on( "click", function() { refreshTableCustomer(); }); $('#customer-table').on('click-cell.bs.table', function(field, value, row, $el) { // alert(value) if (value == 'email_1' || value == 'mobile_phone_1') { return; } customerInfo($el.id); }); //for click bnalloon not hiding -> filter document.getElementById("dropdown-filter").addEventListener('click', function(event) { // alert("click outside"); event.stopPropagation(); }); $('#new-customer').on("click", function() { shown ? $(this).hideBalloon() : $(this).showBalloon(); shown = !shown; }).showBalloon({ position: 'right', html: true, css: { color: 'black' }, contents: ` <div class="row"> <div class="col-sm-6 p-1"> <input style="width: 90px !important;" type="button" onclick="customerModal(true)" id="new-individual-customer" class="btn btn-primary btn-sm" value="Individual" data-toggle="modal" data-target="#modal-customer"></input> </div> <div class="col-sm-6 p-1"> <input style="width: 90px !important;" type="button" onclick="customerModal(false)" id="new-corporate-customer" class="btn btn-primary btn-sm" value="Corporation" data-toggle="modal" data-target="#modal-customer"></input> </div> <div class="col-sm-4 p-1" hidden> <input style="width: 90px !important;" type="button" id="new-import-customer" class="btn btn-primary btn-sm" value="Import"></input> </div> </div> ` }); $('#new-customer').hideBalloon(); $(document).mouseup(function(e) { var container = $("#new-customer"); // if the target of the click isn't the container nor a descendant of the container if (!container.is(e.target) && container.has(e.target).length === 0) { container.hideBalloon(); shown = false; } }); $('#btnCustomerListNoFilter').click(function() { $('#dms').off('change.mychange'); $('#company-filter').off('change.mychange'); $('#gender').off('change.mychange'); $('#type').off('change.mychange'); $('#filter-age').off('change.mychange'); $('#filter-data').off('change.mychange'); $('#customer-actions').off('change.mychange'); $('#dms').val('').trigger('change') $('#company-filter').val('').trigger('change') $('#gender').val('').trigger('change') $('#type').val('').trigger('change') $('#filter-age').val('').trigger('change') $('#filter-data').val('').trigger('change') $('#customer-actions').val('').trigger('change') $('#my_record_filter').prop('checked', false); addFilterListener(); refreshTableCustomer(); }) $('#proceed-button').on("click", function() { if (new_customer_is_individual) { if (isEmpty($('#mod-firstname').val())) { addCustomerModalTabSelectedTab(1); $('#mod-firstname').focus(); sweetAlertSimple('error', 'Oops...', 'Firstname can\'t be left blank') return; } if (isEmpty($('#mod-lastname').val())) { addCustomerModalTabSelectedTab(1); $('#mod-lastname').focus(); sweetAlertSimple('error', 'Oops...', 'Lastname can\'t be left blank') return; } if (!isEmpty($('#mod-birthdate').val())) { cust_dob = new Date($('#mod-birthdate').val()); var cust_today = new Date(); var cust_age = Math.floor((cust_today-cust_dob) / (365.25 * 24 * 60 * 60 * 1000)); // alert(cust_age+' years old'); if(parseInt(cust_age) < 17 ){ addCustomerModalTabSelectedTab(1); $('#mod-birthdate').focus(); sweetAlertSimple('error', 'Oops...', 'Age must be 17 and above.') return; } } } else { if (isEmpty($('#mod-corporation-name').val())) { addCustomerModalTabSelectedTab(1); $('#mod-corporation-name').focus(); sweetAlertSimple('error', 'Oops...', 'Corporation name can\'t be left blank') return; } } if (!checkIfDataSourceIncomplete() && $('#data-source-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(1); $('#data-source-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the data source details first'); return; } if (new_customer_is_individual) { if (isEmpty($('#mod-contact').val())) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Mobile number is required'); return; } if ($('#mod-contact').val().length < 10 || !$('#mod-contact').val().startsWith("9")) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } else { if (isEmpty($('#mod-contact').val()) && isEmpty($('#mod-landline').val())) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Mobile number or landline is required'); return; } if (!isEmpty($('#mod-contact').val())) { if ($('#mod-contact').val().length < 5) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } } // if (isEmpty($('#mod-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Email address is required'); // return; // } // if (!isEmail($('#mod-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Invalid email address'); // return; // } if (!isEmpty($('#mod-email').val())) { if (!isEmail($('#mod-email').val())) { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid email address'); return; } } if (!isEmpty($('#mod-other-email').val())) { if (!isEmail($('#mod-other-email').val())) { addCustomerModalTabSelectedTab(2); $('#mod-other-email').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid other email address'); return; } } var validate_data_contact_person = checkIfContactPersonIncomplete(); if (!validate_data_contact_person[0] && $('#contact-person-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the data of contact person first') return; } else if (!validate_data_contact_person[1]) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Contact person invalid email') return; } else if (!validate_data_contact_person[2]) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Contact person invalid mobile') return; } // if (isEmpty($('#mod-address-1').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-address-1').focus(); // sweetAlertSimple('error', 'Oops...', 'Primary address is required'); // return; // } // if (isEmpty($('#mod-dd-city-1').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-dd-city-1').focus(); // sweetAlertSimple('error', 'Oops...', 'Primary city is required'); // return; // } // if (!isEmpty($('#mod-address-2').val()) && isEmpty($('#mod-dd-city-2').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-dd-city-2').focus(); // sweetAlertSimple('error', 'Oops...', 'Select secondary city'); // return; // } if (!isEmpty($('#mod-dd-city-2').val())) { if (isEmpty($('#mod-address-2').val())) { addCustomerModalTabSelectedTab(2); $('#mod-address-2').focus(); sweetAlertSimple('error', 'Oops...', 'Enter secondary address'); return; } } var validate_data_children_list = checkIfChildrenIncomplete(); if (!validate_data_children_list[0] && $('#children-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(3); $('#children-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the child details first'); return; } else if (!validate_data_children_list[1]) { addCustomerModalTabSelectedTab(3); $('#children-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Children data invalid mobile'); return; } if (!checkIfInterestIncomplete() && $('#interest-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(5); $('#interest-list-table select').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the interest/hobbies details first'); return; } if (!checkIfAffiliationsIncomplete() && $('#affiliations-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(4); $('#affiliations-list-table select').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the affiliations details first'); return; } //MODIFY // /check exist the input if($('#mod-other-mobile-number1').length > 0 && $('#mod-other-mobile-number1').val() != '') { $(this).attr("required", "true"); if ($('#mod-other-mobile-number1').val().length < 10 || !$('#mod-other-mobile-number1').val().startsWith("9")) { addCustomerModalTabSelectedTab(2); alert('error other mobile contact');return; $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val().length > 10) { // $('#mod-other-mobile-number1').val(''); $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val() == $('#mod-contact').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } }else if($('#mod-other-mobile-number1').length ===1 && $('#mod-other-mobile-number1').val()===''){ // console.log('accept validation');return; $("#mod-other-mobile-number1").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-mobile-number2').focus(); return; } else { } if($('#mod-other-mobile-number2').length > 0 && $('#mod-other-mobile-number2').val() != '') { // console.log('accept validation');return; if($('#mod-other-mobile-number2').val().length < 10 || !$('#mod-other-mobile-number2').val().startsWith("9")) { addCustomerModalTabSelectedTab(2);alert('error other mobile contact'); $('#mod-other-mobile-number2').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val() == $('#mod-other-mobile-number2').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } if($('#mod-other-mobile-number2').val() == $('#mod-contact').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } if($('#mod-other-mobile-number1').val().length > 10) { // $('#mod-other-mobile-number1').val(''); $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } else if($('#mod-other-mobile-number2').length ===1 && $('#mod-other-mobile-number2').val()===''){ // console.log('accept validation');return; $("#mod-other-mobile-number2").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-mobile-number2').focus(); return; } else { $('#mod-other-mobile-number2').attr("required", "false"); $('#mod-other-mobile-number2').removeAttr('required'); } // END MODIFY // alert(force_update+ ' - '+force_update_reason); $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '7347482808054211', customer_data: getCustomerAllModalData(), customer_dms: getAllDataSourceTableData(), customer_contact_person: getAllContactPersonTableData(), customer_children: getAllChildrenTableData(), customer_interest: getAllInterestTableData(), customer_affiliations: getAllAffiliationsTableData(), force_update : force_update, force_update_reason:force_update_reason }, beforeSend: function() { //show loader $('#proceed-button').attr('disabled', true); $('.customer-modal-overlay').show(); }, success: function(result) { if (parseInt(result.status) === 1) { sweetAlertSimple('success', 'Nice...', result.message); refreshTableCustomer(); $('#modal-customer').modal('hide'); } else if (parseInt(result.status) === 0) { sweetAlertSimple('error', 'Oops...', result.message); } else if (parseInt(result.status) === 2) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', result.message); if(customer_force_edit){ Swal.fire({ title: 'Update anyway?', input: 'textarea', inputPlaceholder: 'Enter your reason', confirmButtonText: `Save`, showCancelButton: true, inputValidator: (value) => { if (!value) { return 'Enter your reason to proceed.' }else{ force_update = 1; force_update_reason = value; $('#proceed-button').click(); } } }); } } else if (parseInt(result.status) === 3) { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', result.message); if(customer_force_edit){ Swal.fire({ title: 'Update anyway?', input: 'textarea', inputPlaceholder: 'Enter your reason', confirmButtonText: `Save`, showCancelButton: true, inputValidator: (value) => { if (!value) { return 'Enter your reason to proceed.' }else{ force_update = 1; force_update_reason = value; $('#proceed-button').click(); } } }); } } else if (parseInt(result.status) === 4) { addCustomerModalTabSelectedTab(1); $('#data-source-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', result.message); } refreshModalReligion(); // refreshModalCities(); $('#proceed-button').attr('disabled', false); $('.customer-modal-overlay').hide(); force_update = 0; force_update_reason = ''; }, error: handleError }); }); $('#aha-status').on('change',function(){ if($(this).is(':checked')){ $(this).val('1'); }else{ $(this).val('0'); } }); // MODIFY $("#btn-add-mobile").on('click', function(){ // var count = $("#countInputMobile").val(); // count++; let inputMobLengh = $('.mod-div input[name="mob[]"]').length; // alert(inputMobLengh); if(inputMobLengh<2){ let divGrid = $('<div></div>').attr({'class':'mod-div'}); let inputGroup = $('<div></div>').attr({'class':'input-group mb-0 input-other-mob'}); let inputBtl = $('<div></div>').attr({'class' : 'edit-customer input-group-append'}).css("height", "28px");; let inputText = $('<div></div>').attr({'class':'input-group-text'}).text("+63"); let inputjson = $('<input>').attr({'name':'mob[]','id':'mod-other-mobile-number','class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm inputMobile', 'id':'mod-other-mobile-number2','type':'number','maxlength':'10','json-modal':'true'}); let label = $('<label></label>').attr({'for': 'Other Mobile','class':'lbl-forms mx-0 my-0'}).text("Other Mobile"); $(inputBtl).append(inputText); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger'}).click(function(e){ // count--; // $("#countInputMobile").prop("value",count); $(this).closest('.mod-div').remove(); inputMobLengh = inputMobLengh-1; if(inputMobLengh<2){ $("#btn-add-mobile").show(); } else { $("#btn-add-mobile").hide(); } $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); }); //end delete $(inputGroup).append(inputBtl,inputjson,deleteSPan); $(divGrid).append(label,inputGroup); $("#mod-contact-div").append(divGrid); // $("#countInputMobile").val(count); $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); // alert(inputMobLengh); if(inputMobLengh>=1){ $("#btn-add-mobile").hide(); } else{ $("#btn-add-mobile").show(); } } //end if }); $("#btn-add-email").on('click', function(){ // var count = $("#countInputMobile").val(); // count++; let inputEmailCount =$('#email-add input[name="mob-email[]"]').length; if(inputEmailCount<2){ let divGrid = $('<div></div>').attr({'class':'col-sm-12 mb-1 div-email'}); let inputGroup = $('<div></div>').attr({'class':'form-group mb-0'}); let inputGroup2 = $('<div></div>').attr({'class':'input-group'}); let label = $('<label></label>').attr({'class':'lbl-forms mx-0 my-0'}).text("Other Email"); let inputjson = $('<input>').attr({'name':'mob-email[]','id':'mod-other-email','class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm inputMobile','type':'email','json-modal':'true'}); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger','required':true}).click(function(e){ inputEmailCount = inputEmailCount-1; // $("#countInputMobile").prop("value",count); if(inputEmailCount>=1){ $("#btn-add-email").hide(); } else{ $("#btn-add-email").show(); } // alert('fire') $(this).closest('.div-email').remove(); $('#email-add input[name="mob-email[]"]').each(function(index){ $(this).attr('id',"mod-other-email"+(index+1)); }); }); //end delete $(inputGroup2).append(inputjson,deleteSPan); $(inputGroup).append(label,inputGroup2); $(divGrid).append(inputGroup); $('#email-add').append(divGrid); if(inputEmailCount>=1){ $("#btn-add-email").hide(); } else{ $("#btn-add-email").show(); } $('#email-add input[name="mob-email[]"]').each(function(index){ $(this).attr('id',"mod-other-email"+(index+1)); }); } //end if }); // END MODIFY }); ltms_list_uploaded.js 0000644 00000120552 15030155051 0010771 0 ustar 00 var new_customer_is_individual = false; var shown = false; var count_customer_summary = null; var customer_grid = null; var onShowFiltersDialog = function() { if (getCookie("customer_toggle") == null || parseInt($.cookie("customer_toggle")) == 0) { var $table = $('#ltms-table'); $table.bootstrapTable('destroy'); initGrid() $.cookie("customer_toggle", 1); } else { // initList() $.cookie("customer_toggle", 0); } refreshTableCustomer() } function buttonsFunction() { return { grid_refresh: { 'icon': 'fa fa-sync', 'event': 'refreshTableCustomer', 'attributes': { 'title': 'Refresh', 'data-test': 'test123' } }, grid_toggle_on: { 'icon': 'fa fa-toggle-on', 'event': 'onShowFiltersDialog', 'attributes': { 'title': 'Toggle List View', 'data-test': 'test123' } }, grid_toggle_off: { 'icon': 'fa fa-toggle-off', 'event': 'onShowFiltersDialog', 'attributes': { 'title': 'Toggle Grid View', 'data-test': 'test123' } } } } function initGrid() { var $table = $('#ltms-table'); // $table.bootstrapTable('destroy'); $table.bootstrapTable({ formatSearch: function() { return 'Search Customer' }, }); } function initList() { var $table = $('#ltms-table') $table.bootstrapTable('destroy') $table.bootstrapTable({ sidePagination: 'server', formatSearch: function() { return 'Search Customer' }, onSearch: function(text) { $table.addClass('loading'); }, onLoadSuccess: function() { $table.removeClass('loading'); } }); } function customSearch(data, text) { if (getCookie("customer_toggle") != null && $.cookie("customer_toggle") == 1) { refreshTableCustomer(); } return data.filter(function(row) { return row.name.toLowerCase().replace(/\s/g, "").indexOf(text.toLowerCase().replace(/\s/g, "")) > -1 }) } function customerCountSummary() { var dms = ($("#dms").val() == '') ? '0' : $("#dms").val(); var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); var gender = ($("#gender").val() == '') ? 'all' : $("#gender").val(); var type = ($("#type").val() == '') ? '0' : $("#type").val(); var filter_age = ($("#filter-age").val() == '') ? '0' : $("#filter-age").val(); var filter_data = ($("#filter-data").val() == '') ? '0' : $("#filter-data").val(); var filter_month = ($("#filter-month").val() == '') ? '0' : $("#filter-month").val(); var filter_year = ($("#filter-year").val() == '') ? '0' : $("#filter-year").val(); var customer_actions = ($("#customer-actions").val() == '') ? '0' : $("#customer-actions").val(); var my_records = $('#my_record_filter').is(":checked"); if(count_customer_summary != null){ count_customer_summary.abort(); } count_customer_summary = $.ajax({ url: "api/customer_update/customerv2_update.php", type: "POST", dataType: 'json', data: { dms: dms, company: company, type: type, gender: gender, filter_age: filter_age, filter_data: filter_data, filter_month : filter_month, filter_year :filter_year, apiKey: '8666264351338448', my_records : my_records }, beforeSend: function() {}, success: function(result) { // console.log($result); $('#total_customer_count').text(result.total_count); $('#new_customer_count').text(result.pending); $('#updated_customer_count').text(result.updated_customer_count); $('#active_customer_count').text(result.total_is_active ); $('#inactive_customer_count').text(result.total_is_inactive ); // $('#new_today_customer_count').text(result.new_today_customer_count); } }); } function refreshTableCustomer() { if (getCookie("customer_toggle") != null && $.cookie("customer_toggle") == 1) { initGrid() getCustomerGrid(0, 9); showGrid(); } else { initList() var $table = $('#ltms-table') // $table.bootstrapTable('destroy') $(function() { $table.bootstrapTable('refresh', { url: 'app/table/bt_ltms_upload_list.php' }); }) showList(); } customerCountSummary(); } function gotoOffsetCustomer(n) { // alert(n) // $.cookie("customer_list_offset",n); getCustomerGrid(n, 9); } function getCustomerGrid(offset, limit) { var dms = ($("#dms").val() == '') ? '0' : $("#dms").val(); var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); var gender = ($("#gender").val() == '') ? 'all' : $("#gender").val(); var type = ($("#type").val() == '') ? '0' : $("#type").val(); var filter_age = ($("#filter-age").val() == '') ? '0' : $("#filter-age").val(); var filter_data = ($("#filter-data").val() == '') ? '0' : $("#filter-data").val(); var customer_actions = ($("#customer-actions").val() == '') ? '0' : $("#customer-actions").val(); var search = $(".search-input").val(); var my_records = $('#my_record_filter').is(":checked"); if(customer_grid != null){ customer_grid.abort(); } customer_grid = $.ajax({ url: 'app/table/bt_ltms_upload_list.php', type: "POST", dataType: 'json', data: { search: search, grid: 1, offset: offset, limit: limit, dms: dms, company: company, type: type, gender: gender, filter_age: filter_age, filter_data: filter_data, customer_actions: customer_actions, my_records : my_records }, beforeSend: function() { $('#loader-main').show(); }, success: function(result) { // result.total $('#customer-grid-data').html(''); $('#customer-grid-data').append(result.customer_list); $('#customer-grid-data-paging').html(''); // if(result.total <= 0){ // $('#customer-grid-data-paging').append(result.customer_list_paging); // } // if(result.grid_offset > 6){ $('#customer-grid-data-paging').append(result.customer_list_paging); // } $('#loader-main').hide(); } }); } function showGrid() { $("#customer-grid").show(); $("#grid-card").show(); $('#customer-grid-data-paging').show(); $("button[name='grid_toggle_on']").show(); $("#ltms-table").hide(); $(".fixed-table-pagination").hide(); $("button[name='grid_toggle_off']").hide(); } function showList() { $("#ltms-table").show(); $("#grid-card").hide(); $(".fixed-table-pagination").show(); $("button[name='grid_toggle_off']").show(); $("#customer-grid").hide(); $('#customer-grid-data-paging').hide(); $("button[name='grid_toggle_on']").hide(); } function queryParams(params) { var dms = ($("#dms").val() == '') ? '0' : $("#dms").val(); var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); var gender = ($("#gender").val() == '') ? 'all' : $("#gender").val(); var type = ($("#type").val() == '') ? '0' : $("#type").val(); var filter_age = ($("#filter-age").val() == '') ? '0' : $("#filter-age").val(); var filter_data = ($("#filter-data").val() == '') ? '0' : $("#filter-data").val(); var filter_month = ($("#filter-month").val() == '') ? '0' : $("#filter-month").val(); var filter_year = ($("#filter-year").val() == '') ? '0' : $("#filter-year").val(); var customer_actions = ($("#customer-actions").val() == '') ? '0' : $("#customer-actions").val(); var my_records = $('#my_record_filter').is(":checked"); return { search: params.search, offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, dms: dms, company: company, type: type, gender: gender, filter_age: filter_age, filter_data: filter_data, filter_month: filter_month, filter_year : filter_year, customer_actions: customer_actions, my_records : my_records }; } function customerModal(isIndividual) { new_customer_is_individual = isIndividual; $('#proceed-button').text("Add Customer"); $('.customer-modal-overlay').hide(); if (isIndividual) { $('#modal-title').text("New Customera (Individual)"); checkFieldsModal(true); } else { $('#modal-title').text("New Customerb (Corporation)"); checkFieldsModal(false); } resetCustomerModal(); $("#addRowDataSource").click(); } function customerInfo(id) { $.cookie("customer_selected_tab", 'custom-tabs-three-home-tab'); // window.location.href = "customer_view.php?q=" + id; } function addFilterListener(){ $('#dms').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#company-filter').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#gender').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#type').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#filter-data').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#filter-month').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#filter-year').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#filter-age').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); addFilterListenerCustomerAction(); } function addFilterListenerCustomerAction(){ $('#customer-actions').off('change.mychange').on('change.mychange', function() { refreshTableCustomer(); }); } ///////////////////////////////////////////////////////////////////////////////////////////////////// $(document).ready(function() { // if (getCookie("customer_toggle") != null && parseInt($.cookie("customer_toggle")) == 1) { // initGrid() // } else { // initList() // } refreshTableCustomer() addFilterListener(); var $table = $('#ltms-table'); $('#customer_action_all').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('all').trigger('change'); }); $('#customer_action_new').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('new').trigger('change'); }); $('#customer_action_updated').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('updated').trigger('change'); }); $('#customer_action_added').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('added').trigger('change'); }); $('#customer_action_active').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('active').trigger('change'); }); $('#customer_action_inactive').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('inactive').trigger('change'); }); $('#customer_action_pending').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('pending').trigger('change'); }); $('#dms').select2({ placeholder: "DMS Type", allowClear: true }) $('#company-filter').select2({ placeholder: "Company", allowClear: true }) $('#gender').select2({ placeholder: "Gender", allowClear: true }) $('#type').select2({ placeholder: "Customer Type", allowClear: true }) $('#filter-age').select2({ placeholder: "Age", allowClear: true }) $('#filter-data').select2({ placeholder: "Data Type", allowClear: true }) $('#filter-month').select2({ placeholder: "Month", allowClear: true }) $('#filter-year').select2({ placeholder: "Year", allowClear: true }) $('#customer-actions').select2({ placeholder: "Customer Actions", allowClear: true }) $( "#my_record_filter").on( "click", function() { refreshTableCustomer(); }); $('#ltms-table').on('click-cell.bs.table', function(field, value, row, $el) { // alert(value) if (value == 'email_1' || value == 'mobile_phone_1') { return; } customerInfo($el.id); }); //for click bnalloon not hiding -> filter // document.getElementById("dropdown-filter").addEventListener('click', function(event) { // // alert("click outside"); // event.stopPropagation(); // }); $('#new-customer').on("click", function() { shown ? $(this).hideBalloon() : $(this).showBalloon(); shown = !shown; }).showBalloon({ position: 'right', html: true, css: { color: 'black' }, contents: ` <div class="row"> <div class="col-sm-6 p-1"> <input style="width: 90px !important;" type="button" onclick="customerModal(true)" id="new-individual-customer" class="btn btn-primary btn-sm" value="Individual" data-toggle="modal" data-target="#modal-customer"></input> </div> <div class="col-sm-6 p-1"> <input style="width: 90px !important;" type="button" onclick="customerModal(false)" id="new-corporate-customer" class="btn btn-primary btn-sm" value="Corporation" data-toggle="modal" data-target="#modal-customer"></input> </div> <div class="col-sm-4 p-1" hidden> <input style="width: 90px !important;" type="button" id="new-import-customer" class="btn btn-primary btn-sm" value="Import"></input> </div> </div> ` }); $('#new-customer').hideBalloon(); $(document).mouseup(function(e) { var container = $("#new-customer"); // if the target of the click isn't the container nor a descendant of the container if (!container.is(e.target) && container.has(e.target).length === 0) { container.hideBalloon(); shown = false; } }); $('#btnCustomerListNoFilter').click(function() { $('#dms').off('change.mychange'); $('#company-filter').off('change.mychange'); $('#gender').off('change.mychange'); $('#type').off('change.mychange'); $('#filter-age').off('change.mychange'); $('#filter-data').off('change.mychange'); $('#customer-actions').off('change.mychange'); $('#dms').val('').trigger('change') $('#company-filter').val('').trigger('change') $('#gender').val('').trigger('change') $('#type').val('').trigger('change') $('#filter-age').val('').trigger('change') $('#filter-data').val('').trigger('change') $('#customer-actions').val('').trigger('change') $('#my_record_filter').prop('checked', false); addFilterListener(); refreshTableCustomer(); }) $('#proceed-button').on("click", function() { // alert('fire'); return; if (new_customer_is_individual) { if (isEmpty($('#mod-firstname').val())) { addCustomerModalTabSelectedTab(1); $('#mod-firstname').focus(); sweetAlertSimple('error', 'Oops...', 'Firstname can\'t be left blank') return; } if (isEmpty($('#mod-lastname').val())) { addCustomerModalTabSelectedTab(1); $('#mod-lastname').focus(); sweetAlertSimple('error', 'Oops...', 'Lastname can\'t be left blank') return; } if (!isEmpty($('#mod-birthdate').val())) { cust_dob = new Date($('#mod-birthdate').val()); var cust_today = new Date(); var cust_age = Math.floor((cust_today-cust_dob) / (365.25 * 24 * 60 * 60 * 1000)); // alert(cust_age+' years old'); if(parseInt(cust_age) < 17 ){ addCustomerModalTabSelectedTab(1); $('#mod-birthdate').focus(); sweetAlertSimple('error', 'Oops...', 'Age must be 17 and above.') return; } } } else { if (isEmpty($('#mod-corporation-name').val())) { addCustomerModalTabSelectedTab(1); $('#mod-corporation-name').focus(); sweetAlertSimple('error', 'Oops...', 'Corporation name can\'t be left blank') return; } } if (!checkIfDataSourceIncomplete() && $('#data-source-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(1); $('#data-source-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the data source details first'); return; } if (new_customer_is_individual) { if (isEmpty($('#mod-contact').val())) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Mobile number is required'); return; } if ($('#mod-contact').val().length < 10 || !$('#mod-contact').val().startsWith("9")) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } else { if (isEmpty($('#mod-contact').val()) && isEmpty($('#mod-landline').val())) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Mobile number or landline is required'); return; } if (!isEmpty($('#mod-contact').val())) { if ($('#mod-contact').val().length < 5) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } } // if (isEmpty($('#mod-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Email address is required'); // return; // } // if (!isEmail($('#mod-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Invalid email address'); // return; // } if (!isEmpty($('#mod-email').val())) { if (!isEmail($('#mod-email').val())) { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid email address'); return; } } if($('#mod-email').val() =='') { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', 'Email address required'); return; } // if (!isEmpty($('#mod-other-email').val())) { // if (!isEmail($('#mod-other-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-other-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Invalid other email address'); // return; // } // } var validate_data_contact_person = checkIfContactPersonIncomplete(); if (!validate_data_contact_person[0] && $('#contact-person-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the data of contact person first') return; } else if (!validate_data_contact_person[1]) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Contact person invalid email') return; } else if (!validate_data_contact_person[2]) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Contact person invalid mobile') return; } // if (isEmpty($('#mod-address-1').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-address-1').focus(); // sweetAlertSimple('error', 'Oops...', 'Primary address is required'); // return; // } // if (isEmpty($('#mod-dd-city-1').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-dd-city-1').focus(); // sweetAlertSimple('error', 'Oops...', 'Primary city is required'); // return; // } // if (!isEmpty($('#mod-address-2').val()) && isEmpty($('#mod-dd-city-2').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-dd-city-2').focus(); // sweetAlertSimple('error', 'Oops...', 'Select secondary city'); // return; // } if (!isEmpty($('#mod-dd-city-2').val())) { if (isEmpty($('#mod-address-2').val())) { addCustomerModalTabSelectedTab(2); $('#mod-address-2').focus(); sweetAlertSimple('error', 'Oops...', 'Enter secondary address'); return; } } var validate_data_children_list = checkIfChildrenIncomplete(); if (!validate_data_children_list[0] && $('#children-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(3); $('#children-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the child details first'); return; } else if (!validate_data_children_list[1]) { addCustomerModalTabSelectedTab(3); $('#children-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Children data invalid mobile'); return; } if (!checkIfInterestIncomplete() && $('#interest-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(5); $('#interest-list-table select').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the interest/hobbies details first'); return; } if (!checkIfAffiliationsIncomplete() && $('#affiliations-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(4); $('#affiliations-list-table select').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the affiliations details first'); return; } // /check exist the input if($('#mod-other-mobile-number1').length > 0 && $('#mod-other-mobile-number1').val() != '') { $(this).attr("required", "true"); if ($('#mod-other-mobile-number1').val().length < 10 || !$('#mod-other-mobile-number1').val().startsWith("9")) { addCustomerModalTabSelectedTab(2); alert('error other mobile contact');return; $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val().length > 10) { // $('#mod-other-mobile-number1').val(''); $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val() == $('#mod-contact').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } }else if($('#mod-other-mobile-number1').length ===1 && $('#mod-other-mobile-number1').val()===''){ // console.log('accept validation');return; $("#mod-other-mobile-number1").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-mobile-number2').focus(); return; } else { } if($('#mod-other-mobile-number2').length > 0 && $('#mod-other-mobile-number2').val() != '') { // console.log('accept validation');return; if($('#mod-other-mobile-number2').val().length < 10 || !$('#mod-other-mobile-number2').val().startsWith("9")) { addCustomerModalTabSelectedTab(2);alert('error other mobile contact'); $('#mod-other-mobile-number2').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val() == $('#mod-other-mobile-number2').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } if($('#mod-other-mobile-number2').val() == $('#mod-contact').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } if($('#mod-other-mobile-number1').val().length > 10) { // $('#mod-other-mobile-number1').val(''); $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } else if($('#mod-other-mobile-number2').length ===1 && $('#mod-other-mobile-number2').val()===''){ // console.log('accept validation');return; $("#mod-other-mobile-number2").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-mobile-number2').focus(); return; } else { console.log('dito'+$('#mod-other-mobile-number2').length); $('#mod-other-mobile-number2').attr("required", "false"); $('#mod-other-mobile-number2').removeAttr('required'); } // alert(force_update+ ' - '+force_update_reason); // console.log(getAllContactPersonTableData());return; $.ajax({ url: "api/customer_update/customerv2_update.php", method: "POST", dataType: 'json', data: { apiKey: '7347482808054211', customer_data: getCustomerAllModalData(), customer_dms: getAllDataSourceTableData(), customer_contact_person: getAllContactPersonTableData(), customer_children: getAllChildrenTableData(), customer_interest: getAllInterestTableData(), customer_affiliations: getAllAffiliationsTableData(), force_update : force_update, force_update_reason:force_update_reason }, beforeSend: function() { //show loader $('#proceed-button').attr('disabled', true); $('.customer-modal-overlay').show(); }, success: function(result) { if (parseInt(result.status) === 1) { sweetAlertSimple('success', 'Nice...', result.message); refreshTableCustomer(); $('#modal-customer').modal('hide'); } else if (parseInt(result.status) === 0) { sweetAlertSimple('error', 'Oops...', result.message); } else if (parseInt(result.status) === 2) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', result.message); if(customer_force_edit){ Swal.fire({ title: 'Update anyway?', input: 'textarea', inputPlaceholder: 'Enter your reason', confirmButtonText: `Save`, showCancelButton: true, inputValidator: (value) => { if (!value) { return 'Enter your reason to proceed.' }else{ force_update = 1; force_update_reason = value; $('#proceed-button').click(); } } }); } } else if (parseInt(result.status) === 3) { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', result.message); if(customer_force_edit){ Swal.fire({ title: 'Update anyway?', input: 'textarea', inputPlaceholder: 'Enter your reason', confirmButtonText: `Save`, showCancelButton: true, inputValidator: (value) => { if (!value) { return 'Enter your reason to proceed.' }else{ force_update = 1; force_update_reason = value; $('#proceed-button').click(); } } }); } } else if (parseInt(result.status) === 4) { addCustomerModalTabSelectedTab(1); $('#data-source-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', result.message); } refreshModalReligion(); // refreshModalCities(); $('#proceed-button').attr('disabled', false); $('.customer-modal-overlay').hide(); force_update = 0; force_update_reason = ''; }, error: handleError }); }); $('#aha-status').on('change',function(){ if($(this).is(':checked')){ $(this).val('1'); }else{ $(this).val('0'); } }); $("#btn-add-mobile").on('click', function(){ // var count = $("#countInputMobile").val(); // count++; let inputMobLengh = $('.mod-div input[name="mob[]"]').length; // alert(inputMobLengh); if(inputMobLengh<2){ let divGrid = $('<div></div>').attr({'class':'mod-div'}); let inputGroup = $('<div></div>').attr({'class':'input-group mb-0 input-other-mob'}); let inputBtl = $('<div></div>').attr({'class' : 'edit-customer input-group-append'}).css("height", "28px");; let inputText = $('<div></div>').attr({'class':'input-group-text'}).text("+63"); let inputjson = $('<input>').attr({'name':'mob[]','id':'mod-other-mobile-number','class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm inputMobile', 'id':'mod-other-mobile-number2','type':'number','maxlength':'10','json-modal':'true'}); let label = $('<label></label>').attr({'for': 'Other Mobile','class':'lbl-forms mx-0 my-0'}).text("Other Mobile"); $(inputBtl).append(inputText); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger'}).click(function(e){ // count--; // $("#countInputMobile").prop("value",count); $(this).closest('.mod-div').remove(); inputMobLengh = inputMobLengh-1; if(inputMobLengh<2){ $("#btn-add-mobile").show(); } else { $("#btn-add-mobile").hide(); } $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); }); //end delete $(inputGroup).append(inputBtl,inputjson,deleteSPan); $(divGrid).append(label,inputGroup); $("#mod-contact-div").append(divGrid); // $("#countInputMobile").val(count); $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); // alert(inputMobLengh); if(inputMobLengh>=1){ $("#btn-add-mobile").hide(); } else{ $("#btn-add-mobile").show(); } } //end if }); $("#btn-add-email").on('click', function(){ // var count = $("#countInputMobile").val(); // count++; let inputEmailCount =$('#email-add input[name="mob-email[]"]').length; if(inputEmailCount<2){ let divGrid = $('<div></div>').attr({'class':'col-sm-12 mb-1 div-email'}); let inputGroup = $('<div></div>').attr({'class':'form-group mb-0'}); let inputGroup2 = $('<div></div>').attr({'class':'input-group'}); let label = $('<label></label>').attr({'class':'lbl-forms mx-0 my-0'}).text("Other Email"); let inputjson = $('<input>').attr({'name':'mob-email[]','id':'mod-other-email','class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm inputMobile','type':'email','json-modal':'true'}); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger','required':true}).click(function(e){ inputEmailCount = inputEmailCount-1; // $("#countInputMobile").prop("value",count); if(inputEmailCount>=1){ $("#btn-add-email").hide(); } else{ $("#btn-add-email").show(); } // alert('fire') $(this).closest('.div-email').remove(); $('#email-add input[name="mob-email[]"]').each(function(index){ // $(this).attr('id',"mod-other-mobile-number"+(index+1)); $(this).attr('id',"mod-other-email"+(index+1)); }); }); //end delete $(inputGroup2).append(inputjson,deleteSPan); $(inputGroup).append(label,inputGroup2); $(divGrid).append(inputGroup); $('#email-add').append(divGrid); if(inputEmailCount>=1){ $("#btn-add-email").hide(); } else{ $("#btn-add-email").show(); } $('#email-add input[name="mob-email[]"]').each(function(index){ $(this).attr('id',"mod-other-email"+(index+1)); }); } //end if }); }); ltms_uploaded.js 0000644 00000103113 15030155051 0007730 0 ustar 00 var force_update = 0; var force_update_reason = ""; function removeextra() { var initVal = $(this).val(); outputVal = initVal.replace(/[^0-9a-zA-Z]/g, ""); if (initVal != outputVal) { $(this).val(outputVal); } } function removeextranumonly() { var initVal = $(this).val(); outputVal = initVal.replace(/[^0-9()-]/g, ""); if (initVal != outputVal) { $(this).val(outputVal); } } function getCustomerAllModalData() { var /* Create an object. */ obj = {}, /* Create a variable that references the current object (default → obj). */ ref = obj; /* Iterate over every input. */ $("#modal-customer :input").each(function () { /* Cache the id of the input. */ var id = this.id; /* Check whether the nodetype attribute is set to 'parent'. */ if (this.getAttribute("nodetype") == "parent") { /* Set a new object to the property and set ref to refer to it. */ ref = obj[id] = {}; } else { /* Set the value of the input to the referred object. */ if (this.getAttribute("json-modal") == "true") { ref[id] = $(this).val(); } } }); /* Stringify the object and return it. */ return JSON.stringify(obj); } function sweetAlertSimple(icon, title, text) { // Swal.fire({ // icon: icon, // title: title, // text: text, // allowEnterKey: true // default value // }) toastr.remove(); switch (icon) { case "success": toastr.success(text); break; case "info": toastr.info(text); break; case "warning": toastr.warning(text); break; case "error": toastr.error(text); break; } } function getAllDataSourceTableData() { var $table = $("#data-source-list-table"); (rows = []), (header = []); $table.find("thead th").each(function () { var new_header = $(this).html().replace(/\s/g, "_").replace(/\./g, ""); header.push(new_header); }); $table.find("tbody tr").each(function () { var row = {}; $(this) .find("td") .each(function (i) { if (header[i] == "Customer_No") { var key = header[i], value = $(this).find("input").val(); row[key] = value; } else { var key = header[i], value = $(this).find("select").val(); row[key] = value; } }); rows.push(row); }); console.log(rows); return rows; } function checkIfDataSourceIncomplete() { rows = getAllDataSourceTableData(); var dataSourceJsonRow = rows; var hasMatch = true; for (var index = 0; index < dataSourceJsonRow.length; ++index) { var dataSourceJson = dataSourceJsonRow[index]; if ( // dataSourceJson.Customer_No == "" || dataSourceJson.DMS == "" || dataSourceJson.Company == "" || dataSourceJson.Dealer == "" ) { hasMatch = false; break; } } // alert(hasMatch) return hasMatch; } function handleError(xhr, status, error) { //hide loader sweetAlertSimple("error", "Oops...", "Error has occurred, Try again..."); $("#proceed-button").attr("disabled", false); $(".customer-modal-overlay").hide(); force_update = 0; force_update_reason = ""; } function refreshModalCities() { $.ajax({ url: "api/city/city.php", type: "GET", dataType: "json", data: { apiKey: "5881641680981247", }, beforeSend: function () { $("#mod-dd-city-1").prop("disabled", true); $("#mod-dd-city-2").prop("disabled", true); }, success: function (result) { $("#mod-dd-city-1").select2({ data: result, placeholder: "Select City", allowClear: true, }); $("#mod-dd-city-2").select2({ data: result, placeholder: "Select City", allowClear: true, }); $("#mod-dd-city-1").prop("disabled", false); $("#mod-dd-city-2").prop("disabled", false); }, }); } function checkIfChildrenIncomplete() { rows = getAllChildrenTableData(); var childrenJsonRow = rows; var hasMatch = []; hasMatch[0] = true; hasMatch[1] = true; for (var index = 0; index < childrenJsonRow.length; ++index) { var childrenJson = childrenJsonRow[index]; if ( childrenJson.Firstname == "" || childrenJson.Lastname == "" || childrenJson.Birthday == "" ) { hasMatch[0] = false; break; } if (!isEmpty(childrenJson.Mobile)) { if (childrenJson.Mobile.length < 10) { hasMatch[1] = false; break; } } } // alert(hasMatch) return hasMatch; } function getAllChildrenTableData() { var $table = $("#children-list-table"); (rows = []), (header = []); $table.find("thead th").each(function () { header.push($(this).html()); }); $table.find("tbody tr").each(function () { var row = {}; $(this) .find("td") .each(function (i) { var key = header[i], value = $(this).find("input").val(); row[key] = value; }); rows.push(row); }); // alert(JSON.stringify(rows)); // return JSON.stringify(rows); return rows; } function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } function isEmpty(string) { var flag = false; try { if (string.trim() == "") { flag = true; } else if (string == null) { flag = true; } else if (typeof string === "undefined") { flag = true; } } catch (err) { // console.log(err); flag = true; } return flag; } function checkIfContactPersonIncomplete() { rows = getAllContactPersonTableData(); var contactPersonJsonRow = rows; var hasMatch = []; hasMatch[0] = true; hasMatch[1] = true; hasMatch[2] = true; for (var index = 0; index < contactPersonJsonRow.length; ++index) { var contactPersonJson = contactPersonJsonRow[index]; if ( contactPersonJson.Fullname == "" /* || contactPersonJson.Lastname == "" || contactPersonJson.Mobile == ""*/ ) { hasMatch[0] = false; break; } if (contactPersonJson.Email != "") { if (!isEmail(contactPersonJson.Email)) { hasMatch[1] = false; break; } } if (!isEmpty(contactPersonJson.Mobile)) { if (contactPersonJson.Mobile.length < 10) { hasMatch[2] = false; break; } } } // alert(hasMatch) return hasMatch; } function getAllContactPersonTableData() { var $table = $("#contact-person-list-table"); (rows = []), (header = []); $table.find("thead th").each(function () { header.push($(this).html()); }); $table.find("tbody tr").each(function () { var row = {}; $(this) .find("td") .each(function (i) { var key = header[i], value = $(this).find("input").val(); row[key] = value; }); rows.push(row); }); // alert(JSON.stringify(rows)); // return JSON.stringify(rows); return rows; } function addCustomerChildren() { var children_list = document.getElementById("children-list"); const children_list_base = document.querySelector( "#children-list-clone tbody tr" ); children_list.appendChild(children_list_base.cloneNode(true)); // Generate a unique ID for the select> in the new row. var ChildrenIdDateNow = uniqId(); var newChildrenFirstnameId = "children-firstname-" + ChildrenIdDateNow; var newChildrenLastnameId = "children-lastname-" + ChildrenIdDateNow; var newChildrenBirthdayDivId = "div-children-birthday-" + ChildrenIdDateNow; var newChildrenBirthdayAppendId = "append-children-birthday-" + ChildrenIdDateNow; var newChildrenBirthdayId = "children-birthday-" + ChildrenIdDateNow; var newChildrenBirthdayDivId = "children-birthday-div-" + ChildrenIdDateNow; var newChildrenBirthdayAppendId = "children-birthday-append-" + ChildrenIdDateNow; var newChildrenMobileId = "children-mobile-append-" + ChildrenIdDateNow; var item = []; item[0] = newChildrenFirstnameId; item[1] = newChildrenLastnameId; item[2] = newChildrenBirthdayId; item[3] = newChildrenMobileId; $("#mod-children-firstname").attr("id", newChildrenFirstnameId); $("#mod-children-lastname").attr("id", newChildrenLastnameId); $("#mod-children-mobile").attr("id", newChildrenMobileId); $("#mod-children-birthdate") .attr("id", newChildrenBirthdayId) .data("target", "#" + newChildrenBirthdayDivId) .inputmask(); $("#mod-children-birthdate-append") .attr("id", newChildrenBirthdayAppendId) .data("target", "#" + newChildrenBirthdayDivId); $("#mod-children-birthdate-div") .attr("id", newChildrenBirthdayDivId) .datetimepicker({ format: "L", }); return item; } function addCustomerContactPerson() { var contact_person_list = document.getElementById("contact-person-list"); const contact_person_list_base = document.querySelector( "#contact-person-list-clone tbody tr" ); contact_person_list.appendChild(contact_person_list_base.cloneNode(true)); // Generate a unique ID for the select> in the new row. var contactPersonIdDateNow = uniqId(); var newContactPersonFullnameId = "contact-person-fullname-" + contactPersonIdDateNow; var newContactPersonFirstnameId = "contact-person-firstname-" + contactPersonIdDateNow; var newContactPersonLastnameId = "contact-person-lastname-" + contactPersonIdDateNow; var newContactPersonEmailId = "contact-person-email-" + contactPersonIdDateNow; var newContactPersonMobileId = "contact-person-mobile-" + contactPersonIdDateNow; var item = []; item[0] = newContactPersonFullnameId; item[1] = newContactPersonEmailId; item[2] = newContactPersonMobileId; $("#modal-contact-person-fullname").attr("id", newContactPersonFullnameId); $("#modal-contact-person-email").attr("id", newContactPersonEmailId); $("#modal-contact-person-mobile").attr("id", newContactPersonMobileId); return item; } function addRowInterest() { $("#addRow").click(function () { if ( !checkIfInterestIncomplete() && $("#interest-list-table tbody tr").length > 0 ) { sweetAlertSimple( "error", "Oops...", "Complete the interest/hobbies details first" ); } else { addInterestItem(); } }); $("#interest-list").on("click", ".btnRemove", function () { $(this).closest("tr").remove(); }); } function getAllInterestTableData() { var $table = $("#interest-list-table"); (rows = []), (header = []); $table.find("thead th").each(function () { header.push($(this).html()); }); $table.find("tbody tr").each(function () { var row = {}; $(this) .find("td") .each(function (i) { var key = header[i], value = $(this).find("select").val(); row[key] = value; }); rows.push(row); }); // alert(JSON.stringify(rows)); // return JSON.stringify(rows); return rows; } function checkIfInterestIncomplete() { rows = getAllInterestTableData(); var interestJsonRow = rows; var hasMatch = true; for (var index = 0; index < interestJsonRow.length; ++index) { var interestJson = interestJsonRow[index]; if (interestJson.Category == "" || interestJson.Interest == "") { hasMatch = false; break; } } // alert(hasMatch) return hasMatch; } function addRowAffiliations() { $("#addRowAffiliations").click(function () { if ( !checkIfAffiliationsIncomplete() && $("#affiliations-list-table tbody tr").length > 0 ) { sweetAlertSimple( "error", "Oops...", "Complete the affiliation details first" ); } else { addAffiliationsItem(); } }); $("#affiliations-list").on("click", ".btnRemoveAffiliations", function () { $(this).closest("tr").remove(); }); } function getAllAffiliationsTableData() { var $table = $("#affiliations-list-table"); (rows = []), (header = []); $table.find("thead th").each(function () { header.push($(this).html().replace(/\s/g, "_").replace(/\./g, "")); }); $table.find("tbody tr").each(function () { var row = {}; $(this) .find("td") .each(function (i) { var key = header[i], value = $(this).find("select").val(); row[key] = value; }); rows.push(row); }); // alert(JSON.stringify(rows)); // return JSON.stringify(rows); return rows; } function checkIfAffiliationsIncomplete() { rows = getAllAffiliationsTableData(); var jsonRow = rows; var hasMatch = true; for (var index = 0; index < jsonRow.length; ++index) { var json = jsonRow[index]; if (json.Category == "" || json.Affiliations == "") { hasMatch = false; break; } } // alert(hasMatch) return hasMatch; } function refreshModalReligion() { $.ajax({ url: "api/religion/religion.php", method: "POST", data: { apiKey: "2011315786548487", }, cache: false, beforeSend: function () {}, success: function (result) { var obj = jQuery.parseJSON(result); $("#mod-dd-religion").select2({ tags: true, placeholder: "Select Religion", allowClear: true, data: obj, }); }, }); } function resetCustomerModal() { $("#mod-dd-nationality").val("608").trigger("change"); $("#interest-list-table > tbody").empty(); $("#affiliations-list-table > tbody").empty(); $("#contact-person-list-table > tbody").empty(); $("#children-list-table > tbody").empty(); $("#data-source-list-table > tbody").empty(); $("#educational-bg-list-table > tbody").empty(); $("#car-clubs-list-table > tbody").empty(); $("#unit-association-list-table > tbody").empty(); $("#political-clubs-list-table > tbody").empty(); $("#network-marketing-list-table > tbody").empty(); $("#media-publications-list-table > tbody").empty(); $("#sme-groups-list-table > tbody").empty(); $("#fraternities-sororities-list-table > tbody").empty(); $("#facebook-groups-list-table > tbody").empty(); $("#celebrity-influencers-list-table > tbody").empty(); addCustomerModalTabSelectedTab(1); } function checkFieldsModal(isIndividual) { if (isIndividual) { $(".children-stepper").show(); $(".interest-stepper").show(); $(".interest-list").show(); $("#div-mod-firstname").show(); $("#div-mod-middlename").show(); $("#div-mod-lastname").show(); $("#div-mod-suffix").show(); $("#div-corporation-name").hide(); $("#mod-birthdate-label").text("Date of birth"); $("#div-mod-gender").show(); $("#div-mod-nationality").show(); $("#div-mod-occupation").show(); $("#div-mod-marital-status").show(); // $('#mod-contact-corporation-div').hide(); // $('#mod-contact-div').show(); $("#div-mod-spouse").show(); $("#div-mod-no-of-children").show(); $("#div-mod-business-company").show(); $("#div-mod-position").show(); $("#div-mod-religion").show(); $("#div-mod-profession").show(); $("#div-corporation-name").hide(); $("#div-mod-age-of-company").hide(); $("#educational_bg_div").show(); } else { $(".children-stepper").hide(); $(".interest-stepper").hide(); $(".interest-list").hide(); $("#div-mod-firstname").hide(); $("#div-mod-middlename").hide(); $("#div-mod-lastname").hide(); $("#div-mod-suffix").hide(); $("#div-corporation-name").show(); $("#mod-birthdate-label").text("Date Established"); $("#div-mod-gender").hide(); $("#div-mod-nationality").hide(); $("#div-mod-occupation").hide(); $("#div-mod-marital-status").hide(); // $('#mod-contact-corporation-div').show(); // $('#mod-contact-div').hide(); $("#div-mod-spouse").hide(); $("#div-mod-no-of-children").hide(); $("#div-mod-business-company").hide(); $("#div-mod-position").hide(); $("#div-mod-religion").hide(); $("#div-mod-profession").hide(); $("#div-mod-date-established").show(); $("#div-mod-age-of-company").show(); $("#educational_bg_div").hide(); } } function addCustomerModalTabSelectedTab(type) { $("#customer-modal-tab .nav-link").removeClass("active"); $("#customer-modal-tab-content .tab-pane").removeClass("show"); $("#customer-modal-tab-content .tab-pane").removeClass("active"); switch (type) { case 1: $("#customer-modal-tab-information").addClass("active"); $("#customer-modal-information").addClass("active"); $("#customer-modal-information").addClass("show"); break; case 2: $("#customer-modal-tab-contact").addClass("active"); $("#customer-modal-contact").addClass("active"); $("#customer-modal-contact").addClass("show"); break; case 3: $("#customer-modal-tab-children").addClass("active"); $("#customer-modal-children").addClass("active"); $("#customer-modal-children").addClass("show"); break; case 4: $("#customer-modal-tab-affiliations").addClass("active"); $("#customer-modal-affiliations").addClass("active"); $("#customer-modal-affiliations").addClass("show"); break; case 5: $("#customer-modal-tab-interest").addClass("active"); $("#customer-modal-interest").addClass("active"); $("#customer-modal-interest").addClass("show"); break; } } function uniqId() { return Math.round(new Date().getTime() + Math.random() * 100); } function checkIfEmpty(value, row, index) { if (value == "" || value == "-" || value == null) { return "<span style='color:red;'> (Not Provided) </span>"; } return value; } function getCookie(name) { var match = document.cookie.match(RegExp("(?:^|;\\s*)" + name + "=([^;]*)")); return match ? match[1] : null; } function imageFormatter(value, row, index) { return ( '<img width="50px" height="50px" class="user-image img-circle elevation-2" src="dist/img/thumbnail/' + value + '" />' ); } // function initToolTip() { // var bootstrapTooltip = $.fn.tooltip.noConflict(); // $.fn.bstooltip = bootstrapTooltip; // $(".tooltip-me").bstooltip(); // } function tableMobileFormatter(value, row, index) { if ((value != null && value.trim() == "") || value == "-") { return "<span style='color:red;'> (Not Provided) </span>"; } if (value == "-1") { return ""; } return "<a href='tel:" + value + "'>" + value + "</a>"; } function tableNameFormatter(value, row, index) { if ((value != null && value.trim() == "") || value == "-") { return "<span style='color:red;'> (Not Provided) </span>"; } if (value == "-1") { return ""; } //ACTIVE LINK TRIGGER EDIT return "<a href='customer_update_view.php?q=" + row.id + "'>" + value + "</a>"; } function tableEmailFormatter(value, row, index) { if ((value != null && value.trim() == "") || value == "-") { return "<span style='color:red;'> (Not Provided) </span>"; } if (value == "-1") { return ""; } return "<a href='mailto:" + value + "'>" + value + "</a>"; } function addDataSourceItem() { var data_source = document.getElementById("data-source-list"); // console.log('asdfasd'); console.log(data_source); const data_source_base = document.querySelector( "#data-source-list-clone tbody tr" ); data_source.appendChild(data_source_base.cloneNode(true)); console.log(data_source) // Generate a unique ID for the select> in the new row. var dataSourceIdDateNow = uniqId(); var newDataSourceCustomerNoId = "data-source-customer-no-" + dataSourceIdDateNow; var newDataSourceDmsId = "data-source-dms-" + dataSourceIdDateNow; var newDataSourceCompanyId = "data-source-company-" + dataSourceIdDateNow; var newDataSourceDealerId = "data-source-dealer-" + dataSourceIdDateNow; var dataSourceItem = []; dataSourceItem[0] = newDataSourceCustomerNoId; dataSourceItem[1] = newDataSourceDmsId; dataSourceItem[2] = newDataSourceCompanyId; dataSourceItem[3] = newDataSourceDealerId; $("#input-modal-customer-no").attr("id", newDataSourceCustomerNoId); $("#" + newDataSourceCustomerNoId) .on("keyup", removeextra) .blur(removeextra); $("#" + newDataSourceCustomerNoId).on("keypress", function (e) { var regex = new RegExp("^[0-9a-zA-Z]+$"); var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(str)) { return true; } e.preventDefault(); return false; }); $("#select-modal-dms").attr("id", newDataSourceDmsId).select2({ placeholder: "Select DMS", allowClear: true, }); $("#select-modal-company") .attr("id", newDataSourceCompanyId) .select2({ placeholder: "Select Company", allowClear: true, language: { noResults: function () { return "Select DMS first"; }, }, escapeMarkup: function (markup) { return markup; }, ajax: { url: "api/company/company.php", dataType: "json", delay: 1, data: function (data) { return { search: data.term, // search term dms_id: $("#" + newDataSourceDmsId).val(), apiKey: "3568127986733141", }; }, processResults: function (response) { return { results: response, }; }, cache: true, }, }); $("#mod-preferred-moc").select2({ placeholder: "Select mode of contact", allowClear: true, tags: false, minimumResultsForSearch: -1, language: { noResults: function () { return "Select mode of contact"; }, }, escapeMarkup: function (markup) { return markup; }, ajax: { url: "api/mode_of_contact/mode_of_contact.php", dataType: "json", delay: 250, data: function (data) { return { search: data.term, // search term apiKey: "1557741601453763", }; }, processResults: function (response) { return { results: response, }; }, cache: true, }, }); $("#mod-business-company").select2({ placeholder: "Search Company by name, email and mobile", allowClear: true, language: { noResults: function () { return "Search Company by name, email and mobile"; }, }, escapeMarkup: function (markup) { return markup; }, ajax: { url: "api/customer_update/customerv2_update.php", dataType: "json", delay: 250, data: function (data) { return { search: data.term, // search term apiKey: "3975247589935894", }; }, processResults: function (response) { return { results: response, }; }, cache: true, }, }); $("#select-modal-dealer") .attr("id", newDataSourceDealerId) .select2({ placeholder: "Select Dealer", allowClear: true, language: { noResults: function () { return "Search or enter dealer name"; }, }, escapeMarkup: function (markup) { return markup; }, ajax: { url: "api/dealer/dealer.php", dataType: "json", delay: 250, data: function (data) { return { apiKey: "6209267133015033", company_id: $("#" + newDataSourceCompanyId).val(), search: data.term, // search term }; }, processResults: function (response) { return { results: response, }; }, cache: true, }, }); $("#" + newDataSourceDmsId).on("change", function (event) { $("#" + newDataSourceCompanyId) .val("") .trigger("change"); }); $("#" + newDataSourceCompanyId).on("change", function (event) { $("#" + newDataSourceDealerId) .val("") .trigger("change"); }); return dataSourceItem; } function addInterestItem() { // CREATE ROW var interest_list = document.getElementById("interest-list"); const interest_list_base = document.querySelector( "#interest-list-clone tbody tr" ); var interestItem = []; interest_list.appendChild(interest_list_base.cloneNode(true)); // Generate a unique ID for the select> in the new row. var InterestIdDateNow = uniqId(); var newInterestCategoryId = "interest-category-" + InterestIdDateNow; var newInterestContentId = "interest-content-" + InterestIdDateNow; interestItem[0] = newInterestCategoryId; interestItem[1] = newInterestContentId; // alert(interestItem.pop(0)); // alert(interestItem.pop(1)); // Update the ID of the select> in the new row // (it should be the only one with an `id` of '#element'), // and initialize the Select2. $("#select-category").attr("id", newInterestCategoryId).select2({ placeholder: "Select Category", allowClear: true, }); $("#select-content") .attr("id", newInterestContentId) .select2({ tags: true, placeholder: "Select", allowClear: true, language: { noResults: function () { return "Search or enter interest"; }, }, escapeMarkup: function (markup) { return markup; }, placeholder: "Search or enter interest", ajax: { url: "api/interest_hobbies/interest_hobbies.php", dataType: "json", delay: 250, data: function (data) { return { apiKey: "5068581874181452", interestCategory: $("#" + newInterestCategoryId).val(), search: data.term, // search term }; }, processResults: function (response) { return { results: response, }; }, cache: true, }, }); $("#" + newInterestCategoryId).on("select2:select", function (e) { $("#" + newInterestContentId) .val("") .trigger("change"); }); $("#" + newInterestCategoryId).on("select2:unselecting", function (e) { $("#" + newInterestContentId) .val("") .trigger("change"); }); return interestItem; // CREATE ROW } function addAffiliationsItem() { // CREATE ROW var affiliations_list = document.getElementById("affiliations-list"); const affiliations_list_base = document.querySelector( "#affiliations-list-clone tbody tr" ); var affiliationsItem = []; affiliations_list.appendChild(affiliations_list_base.cloneNode(true)); // Generate a unique ID for the select> in the new row. var affiliationsIdDateNow = uniqId(); var newaffiliationsCategoryId = "affiliations-category-" + affiliationsIdDateNow; var newaffiliationsContentId = "affiliations-content-" + affiliationsIdDateNow; affiliationsItem[0] = newaffiliationsCategoryId; affiliationsItem[1] = newaffiliationsContentId; // alert(affiliationsItem.pop(0)); // alert(affiliationsItem.pop(1)); // Update the ID of the select> in the new row // (it should be the only one with an `id` of '#element'), // and initialize the Select2. $("#select-category-affiliations") .attr("id", newaffiliationsCategoryId) .select2({ placeholder: "Select Category", allowClear: true, }); $("#select-content-affiliations") .attr("id", newaffiliationsContentId) .select2({ tags: true, placeholder: "Search or enter affiliations", allowClear: true, language: { noResults: function () { return "Search or enter affiliations"; }, }, escapeMarkup: function (markup) { return markup; }, placeholder: "Search or enter affiliations", ajax: { url: "api/affiliations/affiliations.php", dataType: "json", delay: 250, data: function (data) { return { apiKey: "8048636851659915", affiliationsCategory: $("#" + newaffiliationsCategoryId).val(), search: data.term, // search term }; }, processResults: function (response) { return { results: response, }; }, cache: true, }, }); // $('#' + newaffiliationsCategoryId).on('select2:select', function(e) { // $('#' + newaffiliationsContentId).val('').trigger('change') // }); // $('#' + newaffiliationsCategoryId).on("select2:unselecting", function(e) { // $('#' + newaffiliationsContentId).val('').trigger('change') // }); return affiliationsItem; // CREATE ROW } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $(document).ready(function () { $("#addRowDataSource").click(function () { if ( !checkIfDataSourceIncomplete() && $("#data-source-list-table tbody tr").length > 0 ) { sweetAlertSimple( "error", "Oops...", "Complete the data source details first" ); } else { addDataSourceItem(); } }); $("#data-source-list").on("click", ".btnRemoveDataSource", function () { if ($("#data-source-list-table tbody tr").length < 2) { sweetAlertSimple("error", "Oops...", "Need at least 1 data source"); } else { $(this).closest("tr").remove(); } }); $("#addRowChildren").click(function () { var validate_data_children_list = checkIfChildrenIncomplete(); if ( !validate_data_children_list[0] && $("#children-list-table tbody tr").length > 0 ) { sweetAlertSimple("error", "Oops...", "Complete the child details first"); } else if (!validate_data_children_list[1]) { sweetAlertSimple("error", "Oops...", "Children data invalid mobile"); } else { addCustomerChildren(); } }); $("#children-list").on("click", ".btnRemoveChildren", function () { $(this).closest("tr").remove(); }); $("#addRowContactPerson").click(function () { var validate_data_contact_person = checkIfContactPersonIncomplete(); if ( !validate_data_contact_person[0] && $("#contact-person-list-table tbody tr").length > 0 ) { sweetAlertSimple( "error", "Oops...", "Complete the data of contact person first" ); } else if (!validate_data_contact_person[1]) { sweetAlertSimple("error", "Oops...", "Contact person invalid email"); } else if (!validate_data_contact_person[2]) { sweetAlertSimple("error", "Oops...", "Contact person invalid mobile"); } else { addCustomerContactPerson(); } }); $("#contact-person-list").on("click", ".btnRemoveContactPerson", function () { $(this).closest("tr").remove(); }); //Date picker $("#mod-birth-date").datetimepicker({ format: "L", }); $("#mod-established-date").datetimepicker({ format: "L", }); $("[data-mask]").inputmask(); $("#modal-customer").on("hidden.bs.modal", function (e) { $(this) .find("input,textarea") .val("") .end() .find("select") .prop("selectedIndex", 0) .find("input[type=checkbox], input[type=radio]") .prop("checked", "") .end(); $(".modal-select2").val("").trigger("change"); }); $("#modal-customer").on("shown.bs.modal", function () { $("input:text:visible:first").focus(); }); $(document).on("wheel", "input[type=number]", function (e) { $(this).blur(); }); $("#mod-nature-of-business").select2({ // tags: true, placeholder: "Select Nature of Business", allowClear: true, escapeMarkup: function (markup) { return markup; }, ajax: { url: "api/nature_of_business/nature_of_business.php", dataType: "json", delay: 250, data: function (data) { return { apiKey: "6902545878701742", search: data.term, // search term }; }, processResults: function (response) { return { results: response, }; }, cache: true, }, }); $("#mod-dd-profession").select2({ tags: true, placeholder: "Select Profession", allowClear: true, escapeMarkup: function (markup) { return markup; }, ajax: { url: "api/profession/profession.php", dataType: "json", delay: 250, data: function (data) { return { apiKey: "8920139547181378", search: data.term, // search term }; }, processResults: function (response) { return { results: response, }; }, cache: true, }, }); $("#mod-dd-inquiry").select2({ placeholder: "Select Source of Inquiry", allowClear: true, }); $("#mod-dd-gender").select2({ placeholder: "Select Gender", allowClear: true, minimumResultsForSearch: -1, }); $("#mod-dd-marital-status").select2({ placeholder: "Select Marital Status", allowClear: true, minimumResultsForSearch: -1, }); $("#mod-dd-nationality").select2({ placeholder: "Select Nationality", allowClear: true, }); addRowInterest(); addRowAffiliations(); refreshModalReligion(); refreshModalCities(); // initToolTip(); $('[data-toggle="tooltip"]').tooltip(); }); ltms.js 0000644 00000012630 15030155051 0006056 0 ustar 00 var upload_image_name = []; var myDropzone; function photoDropzoneListener() { Dropzone.autoDiscover = false; // Disable auto-discovery // Initialize Dropzone myDropzone = new Dropzone("#upload-ltms-photo", { url: "api/upload/upload_image_ltms.php", // Ensure the URL is correct autoProcessQueue: false, // Disable auto-upload acceptedFiles: '.png,.jpg,.jpeg', maxFilesize: 40, // Max file size in MB maxFiles: 10, // Max number of files clickable: true, addRemoveLinks: true, dictCancelUpload: 'Cancel', parallelUploads: 10, // Allow multiple files to be uploaded in parallel renameFile: function (file) { var extension = file.name.substr((file.name.lastIndexOf('.') + 1)).toLowerCase(); let newName = uniqImgId() + '.' + extension; upload_image_name.push(newName); return newName; }, init: function () { this.on("maxfilesexceeded", function (file) { alert('Only 10 images allowed.'); this.removeFile(file); return; }); this.on("error", function (file, response) { alert(response || 'Error uploading file.'); }); this.on("success", function (file, response) { sweetAlertSimple('success', 'Nice...',"Successfully uploaded!"); console.log("Success:", response); // Log the success response }); this.on('sending', function (file, xhr, formData) { formData.append("cuid", customer_record_id); formData.append("did", $('#did').val()); }); this.on('complete', function (file) { // Check if all files are uploaded // sweetAlertSimple('success', 'Nice...',"Successfully uploaded!"); if (myDropzone.getQueuedFiles().length === 0 && myDropzone.getUploadingFiles().length === 0) { $('#loading-indicator').hide(); setTimeout(() => { // Refresh the page or update the UI window.location.reload(); }, "1000"); } }); } }); // Handle form submit button click $('#ltms-submit').on('click', function (e) { e.preventDefault(); // Prevent default form submission if (myDropzone.getQueuedFiles().length > 0) { $('#loading-indicator').show(); // Show loading indicator myDropzone.processQueue(); // Upload files if there are any } else { alert('No files to upload.'); } }); } $("#btn-upload-ltms").on('click',function(){ $("#ltms-container").show(); $(this).hide(); $("#customer-ltms-image-data").hide(); }); $("#ltms-submit-cancel").on('click',function(){ // window.location.reload(); $("#ltms-container").hide(); $("#btn-upload-ltms").show(); $("#customer-ltms-image-data").show(); }); function uniqImgId() { var id = Math.round(new Date().getTime() + (Math.random() * 100)); return id; } function removeImage(id) { // alert(id); Swal.fire({ icon: 'warning', html: 'Do you want to remove this image?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { // toastr.remove(); $.ajax({ url: "api/upload/upload_image_ltms.php", method: "POST", data: { apiKey: '9434631886897744', id: id }, cache: false, beforeSend: function() { sweetAlertSimple('info', 'Oops...', 'Removing image...'); }, success: function(data) { // fetchVehicleInfo(vehicle_record_id, customer_record_id) // readVehicleImage(vehicle_record_id); readLtmsUpload(); sweetAlertSimple('success', 'Oops...', 'Image remove successfully.'); // setTimeout(() => { // // Refresh the page or update the UI // window.location.reload(); // }, "1000"); } }) } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) } function readLtmsUpload() { $.ajax({ url: "api/upload/upload_image_ltms.php", type: "POST", dataType: 'json', data: { apiKey: '1164288154587287', cuid:customer_record_id }, beforeSend: function() {}, success: function(result) { // result.total $('#customer-ltms-image-data').html(''); $('#customer-ltms-image-data').append(result.vehicle_image); } }); } readLtmsUpload(); photoDropzoneListener(); customer_view.js 0000644 00000206157 15030155051 0010003 0 ustar 00 //GLOBALS WITTHOUT PHP var customer_record_type = "1"; var vehicle_form = false; //FUNCTIONS function initVehicleSection() { if (!vehicle_form) { vehicle_form = true; $.ajax({ url: 'include/components/customer/modal/vehicle_form.php', type: 'post', beforeSend: function() { $('#customer-vehicle-button').attr('disabled', true); }, success: function(data) { $('#vehicle_form').html(data); $.ajax({ url: 'dist/js/vehicle/vehicle_form.js', type: 'post', success: function(data) { $('#customer-vehicle-button').attr('disabled', false); initVehicle(); }, error: function() { $('#vehicle_form').text('An error occurred'); } }); }, error: function() { $('#vehicle_form').text('An error occurred'); } }); } else { $('#modal-vehicle').modal('show'); initOwnerSelect2(); } } function refreshTableLogs() { var $table = $('#logs-table') $table.bootstrapTable('destroy').bootstrapTable(); $(function() { $table.bootstrapTable('refresh', { url: 'app/table/customer_log.php' }); }) } function queryParamsLogs(params) { console.log(params) return { search: params.search, offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, customer_id: customer_record_id }; } function queryParamsSales(params) { return { search: params.search, offset: params.offset, limit: params.limit, customer_id: customer_record_id }; } function queryParamsService(params) { return { search: params.search, offset: params.offset, limit: params.limit, customer_id: customer_record_id }; } function queryParamsCorporationCustomer(params) { return { search: params.search, offset: params.offset, limit: params.limit, customer_id: customer_record_id, customer_corporation: true }; } function readCustomerSalesImage() { $.ajax({ url: "api/customer/customerv2.php", type: "POST", dataType: 'json', data: { apiKey: '7472626829226859', customer_id: customer_record_id }, beforeSend: function() { $('#loader').show(); }, success: function(result) { // result.total $('#customer-sales-image-data').html(''); $('#customer-sales-image-data').append(result.sales_image); $('#loader').hide(); } }); } function readCustomerChildren(isModal) { $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '8307826786414874', customer_id: customer_record_id }, beforeSend: function() {}, success: function(result) { var obj = jQuery.parseJSON(JSON.stringify(result)); var index = 0; if (isModal) { if (obj.length > 0) { // $('#unit_association').click(); } } else { $('#information_family_list').empty() $("#information_family_list").append( '<li class="list-group-item lbl-forms-sm-customer-main"><strong>Children/s List</strong></li>' ); if (obj.length > 0) { $('#information_family_div').show(); $('#family-page-footer').hide(); } else { $('#information_family_div').hide(); $('#family-page-footer').show(); } } var count_delay = 0; $.each(obj, function(key, value) { setTimeout(function() { if (isModal) { var item = addCustomerChildren(); let $elementFirstname = $('#' + item[0]); let $elementLastname = $('#' + item[1]); let $elementBirthday = $('#' + item[2]); let $elementMobile = $('#' + item[3]); $elementFirstname.val(value.first_name); $elementLastname.val(value.last_name); $elementBirthday.val(value.date_of_birth); $elementMobile.val(value.mobile_phone); } else { var new_mobile = (value.mobile_phone != '') ? '+63' + value .mobile_phone : ''; $("#information_family_list").append(` <li class="list-group-item lbl-forms-sm-customer-main"> <div class="row"> <div class="col-sm-6"><strong>Name: </strong> ` + value.first_name + ' ' + value.last_name + ` </div> <div class="col-sm-3"><strong>Birthday: </strong>` + value.date_of_birth + ` </div> <div class="col-sm-3"><strong>Mobile: </strong><a href="tel:` + new_mobile + `" >` + new_mobile + ` </a> </div> </div> </li> `); } }, count_delay * 250); count_delay++; }); } }); } function readCustomerAffiliations(isModal) { $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '5660696728127200', customer_id: customer_record_id }, beforeSend: function() {}, success: function(result) { var obj = jQuery.parseJSON(JSON.stringify(result)); var index = 0; if (isModal) { if (obj.length > 0) { // $('#unit_association').click(); } } else { $('#information_affiliations_list').empty() $("#information_affiliations_list").append( // '<li class="list-group-item lbl-forms-sm-customer-main"><strong>Village or Condo Homeowners Association</strong></li>' ); if (obj.length > 0) { $('#information_affiliations_div').show(); $('#affiliations-page-footer').hide(); } else { $('#information_affiliations_div').hide(); $('#affiliations-page-footer').show(); } } var count_delay = 0; $.each(obj, function(key, value) { setTimeout(function() { if (isModal) { var item = addAffiliationsItem(); let $elementCategory = $('#' + item[0]); $elementCategory.val(value .affiliation_category).trigger('change'); let $elementContent = $('#' + item[1]); var newContent = new Option(value.affiliation_content, value .affiliation_content, true, true) $elementContent.append(newContent).trigger('change'); } else { $("#information_affiliations_list").append(` <li class="list-group-item lbl-forms-sm-customer-main"> <div class="row"> <div class="col-sm-3"><strong>Category: </strong> ` + value.affiliation_category_name + ` </div> <div class="col-sm-9"><strong>Name: </strong>` + value.affiliation_content + ` </a> </div> </div> </li> `); } }, count_delay * 250); count_delay++; }); } }); } function fetchCustomerInfo(customer_record_id) { $("#profileDisplay").attr("src", "dist/img/customer/default.png"); $(".customer-data-side").text(''); $(".basic-info-name").text(''); $(".basic-info-email").text(''); $(".basic-info-mobile").text(''); $(".basic-info-type").text(''); $('#loader').show(); $('#h3-card-title').text("Customer Profile"); $('#customer-about-me').show(); $('#customer-details').show(); $('#information-customer').show(); $('#customer-vehicle').show(); $('#customer-service').show(); $('#customer-sales').show(); $('#customer-corporation-individual').show(); readCustomerInformationMain(); readCustomerInterestMain(); readCustomerContactPersonMain(); readCustomerChildren(false); readCustomerAffiliations(false); setCustomerTab(); } function setCustomerTab(){ hideCustomerTabActionButton(); removeTabActive(); var selected_tab = ''; if(isEmpty($.cookie("customer_selected_tab"))) { //set default tab $.cookie("customer_selected_tab",'custom-tabs-three-home-tab') selected_tab = $.cookie("customer_selected_tab"); }else{ selected_tab = $.cookie("customer_selected_tab"); } //show tab and content $('#'+selected_tab).addClass('active') $('#'+selected_tab+'-content').addClass('active').addClass('show') //additional condition here switch (selected_tab) { case 'custom-tabs-three-home-tab': $('#customer-info-button').show(); break; case 'custom-tabs-three-hobbies-tab': $('#customer-info-button').show(); break; case 'custom-tabs-three-family-tab': $('#customer-info-button').show(); break; case 'custom-tabs-vehicle-tab': $('#customer-vehicle-button').show(); var offset_n = 0; if (!isEmpty($.cookie("vehicle_list_offset"))) { offset_n = parseInt($.cookie("vehicle_list_offset")); } console.log('111') getVehiclesGrid(offset_n, 9); break; case 'custom-tabs-service-tab': refreshTableService(); break; case 'custom-tabs-sales-tab': refreshTableSales(); break; case 'custom-tabs-three-individuals-tab': refreshTableCorporationIndividual(); break; case 'custom-tabs-three-gallery-tab': readCustomerSalesImage(); break; case 'custom-tabs-customer-logs-tab': refreshTableLogs(); break; case 'custom-tabs-customer-activities-tab': refreshTableActivities(); break; case 'custom-tabs-insurance-tab': initTableFinance(); getVehicles(); break; } } // start --------------------- appended code -> khel (insurance tab) var arr_found = new Array(); function initTableFinance() { var $table = $('#finance-table') $table.bootstrapTable('destroy').bootstrapTable({ // onLoadSuccess: function(data) { // // detailsCount(start_date, end_date); // } }); } function refreshFinanceTable() { // alert(JSON.stringify(arr_found)); return; var $table = $('#finance-table') $(function() { $table.bootstrapTable('refresh', { // 7 url: 'app/table/finance_table.php' }); }) } function queryParamsFinanceTable(params) { return { search: params.search, offset: params.offset, limit: params.limit, plate_cs_number: arr_found, type: 7 }; } function getVehicles() { $.ajax({ url: "api/customer/customer_insurance.php", method: "POST", dataType: 'json', data: { type: 1, customer_id: customer_record_id }, beforeSend: function() { }, success: function(result) { // alert(JSON.stringify(result)); return; getFniOfVehicle(result); } }); } function getFniOfVehicle(itemsArr){ $.ajax({ url: "api/customer/customer_fni.php", method: "POST", dataType: 'json', data: { arr: itemsArr, type: 1 }, success: function(result){ if(result.length === 0){ arr_found = 0; } else { arr_found = result; } refreshFinanceTable(); } }); } function addToTable(arr){ $.ajax({ url: "api/customer/customer_fni.php", method: "POST", // dataType: 'json', data: { type: 2, arr: arr }, success: function(result){ $('#table_data').prepend(result); } }); } // end --------------------- appended code -> khel (insurance tab) function checkFieldsMain(customer_type) { if (parseInt(customer_type) === 1) { $('#information_dob_span').text('Date of birth'); $('#information_gender_div').show(); $('#information_religion_div').show(); $('#information_nationality_div').show(); $('#information_business_company_name_div').show(); $('#information_position_div').show(); $('#information_marital_status_div').show(); $('#information_spouse_div').show(); $('#div-mod-no-of-children_div').show(); // $('#information_interest_hobbies_div').show(); $('#information_profession_div').show(); $('#customer-family-tab').show(); $('#customer-corporation_individuals-tab').hide(); } else if (parseInt(customer_type) === 2) { $('#information_dob_span').text('Date established'); $('#information_gender_div').hide(); $('#information_religion_div').hide(); $('#information_nationality_div').hide(); $('#information_business_company_name_div').hide(); $('#information_position_div').hide(); $('#information_marital_status_div').hide(); $('#information_spouse_div').hide(); $('#div-mod-no-of-children_div').hide(); // $('#information_interest_hobbies_div').hide(); $('#information_profession_div').hide(); $('#customer-family-tab').hide(); $('#customer-corporation_individuals-tab').show(); } } function readCustomerInformationMain() { // return false; $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '8361020315855100', customer_id: customer_record_id }, beforeSend: function() {}, success: function(result) { var json = JSON.stringify(result); data = JSON.parse(json)[0]; if(isEmpty(data['customer_record_id'])){ window.location.href ='customer.php'; return; } $.each(data, function(i, n) { console.log('i :'+i+ ' n : '+n); var excemptedFields = ["main_corporation_name", "main_first_name", "main_middle_name", "main_last_name", "information_modified_by", "information_date_modified" ]; if (excemptedFields.indexOf(i) < 0) { //excempted list $("#" + i).css('color', '') if (isEmpty(n)) { $("#" + i).text('(Not Provided)'); $("#" + i).val('(Not Provided)'); $("#" + i).css('color', 'red') } else { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') $("#" + i).css('color', '007bff') } } else { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') } }); // if(){ // } if(isEmpty(data['information_modified_by'])){ $("#information_modified_by_span").hide(); }else{ $("#information_modified_by_span").show(); } if(isEmpty(data['information_date_modified'])){ $("#information_date_modified_span").hide(); }else{ $("#information_date_modified_span").show(); } customer_record_type = data['customer_type_id']; checkFieldsMain(customer_record_type); $(".contact-click").attr("href", "tel:" + $('#main_customer_mobile').text()) $(".landline-click").attr("href", "tel:" + $('#main_customer_landline').text()) $(".contact2-click").attr("href", "tel:" + $('#main_customer_mobile_2').text()) $(".business-click").attr("href", "tel:" + $('#main_customer_business_mobile').text()) $(".residential-click").attr("href", "tel:" + $('#main_customer_home_mobile').text()) $(".viber-click").attr("href", "viber://chat?number=" + $('#main_viber').text()) $(".facebook-click").attr("href", "http://www.facebook.com/" + $('#main_facebook').text()) $(".instagram-click").attr("href", "http://instagram.com/_u/" + $('#main_instagram').text()) $(".whatsapp-click").attr("href", "https://wa.me/" + $('#main_whatsapp').text()) $(".telegram-click").attr("href", "https://t.me/" + $('#main_telegram').text()) $(".website-click").attr("href", "http://" + $('#main_website_link').text()) $(".email-click").attr("href", "mailto:" + $('#main_email').text()) $(".email2-click").attr("href", "mailto:" + $('#main_customer_email_2').text()) $("#profileDisplay").attr("src", "dist/img/customer/" + data['photo']); $("#profileDisplay_pop").attr("href", "dist/img/customer/" + data['photo']); $('#loader').hide(); }, error: function(xhr, status, error) { $('#loader').hide(); back(); // sweetAlertSimple('error', 'Oops...', 'Error has occurred, Try again...'); toastr.remove(); toastr.error('Error has occurred, Try again...'); } }); } function readCustomerInterestMain() { $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '6579442853321353', customer_id: customer_record_id }, beforeSend: function() {}, success: function(result) { var obj = jQuery.parseJSON(JSON.stringify(result)); var index = 0; $('#information_interest_hobbies_list').empty() $("#information_interest_hobbies_list").append( '<li class="list-group-item lbl-forms-sm-customer-main"><strong>Interest/Hobbies</strong></li>' ); if (obj.length > 0) { $('#information_interest_hobbies_div').show(); } else { $('#information_interest_hobbies_div').hide(); } var count_delay = 0; $.each(obj, function(key, value) { setTimeout(function() { $("#information_interest_hobbies_list").append(` <li class="list-group-item lbl-forms-sm-customer-main"> <div class="row"> <div class="col-sm-6"> ` + value.interest_content + ` </div> <div class="col-sm-6"> <span class="badge badge-success"> ` + value.interest_category_name + ` </span> </div> </div> </li> `); }, count_delay * 250); count_delay++; }); } }); } function readCustomerContactPersonMain() { $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '4788616921820004', customer_id: customer_record_id }, beforeSend: function() {}, success: function(result) { var obj = jQuery.parseJSON(JSON.stringify(result)); var index = 0; $('#information_contact_person_list').empty() $("#information_contact_person_list").append( '<li class="list-group-item lbl-forms-sm-customer-main"><strong>Contact Person</strong></li>' ); if (obj.length > 0) { $('#information_contact_person_div').show(); } else { $('#information_contact_person_div').hide(); } var count_delay = 0; $.each(obj, function(key, value) { setTimeout(function() { $("#information_contact_person_list").append(` <li class="list-group-item lbl-forms-sm-customer-main"> <div class="row"> <div class="col-sm-5"> ` + value.full_name + ` </div> <div class="col-sm-3"> <a href="tel:` + ((isEmpty(value.mobile_phone)) ? '' : value.mobile_phone) + `"> ` + ((isEmpty(value.mobile_phone)) ? '' : '+63' + value.mobile_phone) + ` </a> </div> <div class="col-sm-4"> <a href="mailto:` + value.email + `"> ` + value.email + ` </a> </div> </div> </li> `); }, count_delay * 250); count_delay++; }); } }); } function hideCustomerTabActionButton() { $('#customer-info-button').hide(); $('#customer-gallery-button').hide(); $('#customer-vehicle-button').hide(); } function removeTabActive() { $('.customer-tab').removeClass('active') $('.customer-tab-content').removeClass('active').removeClass('show') } function gotoOffset(n) { $.cookie("vehicle_list_offset", n); console.log('222') getVehiclesGrid(n, 9); } function getVehiclesGrid(offset, limit) { $.ajax({ url: "app/table/vehiclev2.php", type: "POST", dataType: 'json', data: { customer_id: customer_record_id, grid: 1, offset: offset, limit: limit }, beforeSend: function() { $('#loader-vehicle').show(); }, success: function(result) { // result.total $('#customer-owned-vehicle').html(''); $('#customer-owned-vehicle').append(result.vehicle_list); $('#customer-owned-vehicle-paging').html(''); if (result.total <= 0) { $('#customer-owned-vehicle-paging').append(result.vehicle_list_paging); } if (result.grid_offset > 6) { $('#customer-owned-vehicle-paging').append(result.vehicle_list_paging); } $('#loader-vehicle').hide(); } }); } function customerVehicleInfo(grid_vehicle_id) { $.cookie("vehicle_selected_tab",'custom-tabs-three-home-tab') window.location.href = "vehicle_view.php?q=" + grid_vehicle_id; } function refreshTableService() { var $table = $('#service-table') $table.bootstrapTable('destroy').bootstrapTable(); $(function() { $table.bootstrapTable('refresh', { url: 'app/table/service.php' }); }) } function refreshTableCorporationIndividual() { var $table = $('#corporation-individual') $(function() { $table.bootstrapTable('refresh', { url: 'app/table/bt_customer_list.php' }); }) } function refreshTableSales() { var $table = $('#sales-table') $table.bootstrapTable('destroy').bootstrapTable(); $(function() { $table.bootstrapTable('refresh', { url: 'app/table/sales.php' }); }) } function back() { window.history.back(); } function customerModal() { $('#proceed-button').text("Save changes"); $('#proceed-button').attr('disabled', true); $('.customer-modal-overlay').show(); if (parseInt(customer_record_type) === 1) { $('#modal-title').text("Edit Customer Information (Individual)"); checkFieldsModal(true); } else if (parseInt(customer_record_type) === 2) { $('#modal-title').text("Edit Customer Information (Corporation)"); checkFieldsModal(false); } resetCustomerModal(); //fetch data and put to fields readCustomerProfile(); } function readCustomerProfile() { readCustomerInformation(); readCustomerProfileDataSource(); readCustomerContactPerson(); readCustomerChildren(true); readCustomerProfileInterest(); readCustomerAffiliations(true); } function readCustomerInformation() { $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '3463916057587803', customer_id: customer_record_id }, beforeSend: function() {}, success: function(result) { $('.customer-modal-overlay').hide(); $('#proceed-button').attr('disabled', false); var json = JSON.stringify(result); data = JSON.parse(json)[0]; $.each(data, function(i, n) { console.log('i :'+i+' n:'+n); if (i == 'mod-nature-of-business' && n != 0) { var newOption = new Option(data['mod-nature-of-business-name'], data[ 'mod-nature-of-business-name'], true, true); $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-preferred-moc' && n != 0) { var newOption = new Option(data['mod-preferred-moc-name'], data['mod-preferred-moc-name'], true, true); $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-dd-profession' && n != 0) { var newOption = new Option(data['mod-dd-profession-name'], data[ 'mod-dd-profession-name'], true, true); $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-business-company' && n != 0) { var newOption = new Option(data['mod-business-company-name'], data[ 'mod-business-company'], true, true); $("#" + i).append(newOption).trigger('change'); } else if (i == 'aha-status' ) { if(parseInt(data['aha-status'])){ $('#aha-status').prop('checked', true).trigger('change') $('#aha-status').val('1'); } } else { // MODIFY if(i =='mod-other-mobile-number1' && n.length>0){ $("#countInputMobile").val(1); var count =$("#countInputMobile").val(); appendOtherContact(count); } if(i =='mod-other-mobile-number2' && n.length>0){ $("#countInputMobile").val(2); var count =$("#countInputMobile").val(); appendOtherContact(count); } if(i =='mod-other-email1' && n.length > 0){ console.log('email1'); appendOtherEmail(1); } if(i =='mod-other-email2' && n!=null && n.length > 0){ console.log('email2'); appendOtherEmail(2); } // END MODIFY $("#" + i).val(n); $("#" + i).trigger('change') } }); } }); } // MODIFY function appendOtherContact(count) { let inputMobLengh = $('.mod-div input[name="mob[]"]').length; console.log('count :'+inputMobLengh); if(inputMobLengh <2){ var inputCount = $("#countInputMobile").val(); let divGrid = $('<div></div>').attr({'class':'mod-div'}); let inputGroup = $('<div></div>').attr({'class':'input-group mb-0 input-other-mob'}); let inputBtl = $('<div></div>').attr({'class' : 'edit-customer input-group-append'}).css("height", "28px");; let inputText = $('<div></div>').attr({'class':'input-group-text'}).text("+63"); let inputjson = $('<input>').attr({'name':'mob[]','id':'mod-other-mobile-number','class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm', 'id':'mod-other-mobile-number','type':'number','maxlength':'10','json-modal':'true','oninput':'"this.value=this.value.slice(0,this.maxLength)"'}); let label = $('<label></label>').attr({'for': 'Other Mobile ','class':'lbl-forms mx-0 my-0'}).text("Other Mobile"); $(inputBtl).append(inputText); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger'}).click(function(e){ $(this).closest('.mod-div').remove(); $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); inputMobLengh = inputMobLengh-1; if(inputMobLengh<1){ $("#btn-add-mobile").show(); } else{ $("#btn-add-mobile").hide(); } }); //end delete $(inputGroup).append(inputBtl,inputjson,deleteSPan); $(divGrid).append(label,inputGroup); $("#mod-contact-div").append(divGrid); $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); if(inputMobLengh<1){ $("#btn-add-mobile").show(); } else{ $("#btn-add-mobile").hide(); } }//end if } function appendOtherEmail(count){ if($('#email-add input[name="mob-email[]"]').length <=1){ let divGrid = $('<div></div>').attr({'class':'col-sm-12 mb-1 div-email'}); let inputGroup = $('<div></div>').attr({'class':'form-group mb-0'}); let inputGroup2 = $('<div></div>').attr({'class':'input-group'}); let label = $('<label></label>').attr({'class':'lbl-forms mx-0 my-0'}).text("Other Email"); let inputjson = $('<input>').attr({'name':'mob-email[]','id':'mod-other-email'+count,'class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm inputMobile','type':'email','json-modal':'true'}); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger'}).click(function(e){ $(this).closest('.div-email').remove(); $('#email-add input[name="mob-email[]"]').each(function(index){ $(this).attr('id',"mod-other-email"+(index+1)); }); if(($('#email-add input[name="mob-email[]"]').length)>=3){ $("#btn-add-email").hide(); } else { $("#btn-add-email").show(); } }); //end delete $(inputGroup2).append(inputjson,deleteSPan); $(inputGroup).append(label,inputGroup2); $(divGrid).append(inputGroup); $('#email-add').append(divGrid); $('#email-add input[name="mob-email[]"]').each(function(index){ $(this).attr('id',"mod-other-email"+(index+1)); }); if(($('#email-add input[name="mob-email[]"]').length)>=2){ $("#btn-add-email").hide(); } else { $("#btn-add-email").show(); } }//end if } // END MODIFY function readCustomerProfileDataSource() { $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '3099751888433363', customer_id: customer_record_id }, beforeSend: function() {}, success: function(result) { var obj = jQuery.parseJSON(JSON.stringify(result)); var index = 0; var count_delay = 0; $.each(obj, function(key, value) { setTimeout(function() { var dataSourceItem = addDataSourceItem(); let $dataSourceCustomerNo = $('#' + dataSourceItem[0]); $dataSourceCustomerNo.val(value.customer_dms_id); let $dataSourceDMS = $('#' + dataSourceItem[1]); $dataSourceDMS.val(value.dms_id).trigger('change'); let $dataSourceCompany = $('#' + dataSourceItem[2]); var newCompanyContent = new Option(value.company_name, value .company_id, true, true) $dataSourceCompany.append(newCompanyContent).trigger('change'); let $dataSourceDealer = $('#' + dataSourceItem[3]); var newDealerContent = new Option(value.dealer_name, value .dealer_id, true, true) $dataSourceDealer.append(newDealerContent).trigger('change'); }, count_delay * 250); count_delay++; }); } }); } function readCustomerContactPerson() { $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '4788616921820004', customer_id: customer_record_id }, beforeSend: function() {}, success: function(result) { var obj = jQuery.parseJSON(JSON.stringify(result)); var index = 0; var count_delay = 0; $.each(obj, function(key, value) { setTimeout(function() { var item = addCustomerContactPerson(); let $elementFullname = $('#' + item[0]); let $elementEmail = $('#' + item[1]); let $elementMobile = $('#' + item[2]); $elementFullname.val(value.full_name); $elementEmail.val(value.email); $elementMobile.val(value.mobile_phone); }, count_delay * 250); count_delay++; }); } }); } function readCustomerProfileInterest() { $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '6579442853321353', customer_id: customer_record_id }, beforeSend: function() {}, success: function(result) { var obj = jQuery.parseJSON(JSON.stringify(result)); var index = 0; if (obj.length > 0) { // $('#intereset_hobbies_div').click(); } var count_delay = 0; $.each(obj, function(key, value) { setTimeout(function() { var interestItem = addInterestItem(); let $elementInterestCategory = $('#' + interestItem[0]); // let val = $elementInterestCategory.find("option:contains('" + value // .interest_category + "')").val() $elementInterestCategory.val(value .interest_category).trigger('change'); let $elementInterestContent = $('#' + interestItem[1]); var newInterestContent = new Option(value.interest_content, value .interest_content, true, true) $elementInterestContent.append(newInterestContent).trigger( 'change'); }, count_delay * 250); count_delay++; }); } }); } function removeCustomer(customer_record_id){ Swal.fire({ icon: 'question', html: 'Are you sure you want to remove this customer?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '3695340036334748', customer_id: customer_record_id }, beforeSend: function() { sweetAlertSimple('info', 'Oops...', 'Removing customer...') }, success: function(result) { if(parseInt(result.status) === 1) { sweetAlertSimple('success', 'Nice...', result.message); var url = location_url+"customer.php"; window.location.href = url; }else{ sweetAlertSimple('error', 'Oops...', result.message) } }, error: function() { sweetAlertSimple('error', 'Oops...', 'Error has been occurred, please try again.') } }); } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) } //END FUNCTIONS $(function() { fetchCustomerInfo(customer_record_id); $('#corporation-individual').on('click-cell.bs.table', function(field, value, row, $el) { if (value == 'email_1' || value == 'mobile_phone_1') { return; } // $.cookie("tab_open_view", 1); $.cookie("customer_selected_tab", 'custom-tabs-three-home-tab'); window.location.href = "customer_view.php?q=" + $el.id; }); $('.customer-tab').on('click',function(event){ console.log(this.id); $.cookie("customer_selected_tab", this.id); setCustomerTab(); }); $('#service-table').on('click-cell.bs.table', function(field, value, row, $el) { // window.location.hash = 'data_information'; //Do the Ajax request for getting customer full profile information var id = $el.id; var customer_id = $el.customer_id; var ro_number = $el.ro_number; $('#loader').show(); $.cookie("service_customer_id", customer_id); $.cookie("service_service_id", id); $.cookie("service_ro_number", ro_number); var url = location_url+"service.php#service_data"; window.location.href = url; }); $('#sales-table').on('click-cell.bs.table', function(field, value, row, $el) { //Do the Ajax request for getting customer full profile information var id = $el.id; var customer_id = $el.customer_id; var vehicle_id = $el.vehicle_id; $('#loader').show(); $.cookie("sale_customer_id", customer_id); $.cookie("sale_sale_id", id); $.cookie("sale_vehicle_id", vehicle_id); var url = location_url+"sales.php#sales_data"; window.location.href = url; }); $(document).on('click', '[data-toggle="lightbox"]', function(event) { event.preventDefault(); $(this).ekkoLightbox({ alwaysShowClose: false, loadingMessage: "Loading…", }); }); $('#customer-vehicle-button').click(function() { initVehicleSection(); }) $('#proceed-button').on("click", function() { // console.log(getCustomerAllModalData());return; // validate all data if (parseInt(customer_record_type) === 1) { if (isEmpty($('#mod-firstname').val())) { addCustomerModalTabSelectedTab(1); $('#mod-firstname').focus(); sweetAlertSimple('error', 'Oops...', 'Firstname can\'t be left blank') return; } if (isEmpty($('#mod-lastname').val())) { addCustomerModalTabSelectedTab(1); $('#mod-lastname').focus(); sweetAlertSimple('error', 'Oops...', 'Lastname can\'t be left blank') return; } if (!isEmpty($('#mod-birthdate').val())) { cust_dob = new Date($('#mod-birthdate').val()); var cust_today = new Date(); var cust_age = Math.floor((cust_today-cust_dob) / (365.25 * 24 * 60 * 60 * 1000)); if(parseInt(cust_age) < 17 ){ addCustomerModalTabSelectedTab(1); $('#mod-birthdate').focus(); sweetAlertSimple('error', 'Oops...', 'Age must be 17 and above.') return; } } } else if (parseInt(customer_record_type) === 2) { if (isEmpty($('#mod-corporation-name').val())) { addCustomerModalTabSelectedTab(1); $('#mod-corporation-name').focus(); sweetAlertSimple('error', 'Oops...', 'Corporation name can\'t be left blank') return; } } if (!checkIfDataSourceIncomplete() && $('#data-source-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(1); $('#data-source-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the data source details first'); return; } if (parseInt(customer_record_type) === 1) { if (isEmpty($('#mod-contact').val())) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Mobile number is required'); return; } if ($('#mod-contact').val().length < 10 || !$('#mod-contact').val().startsWith("9")) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } //MODIFY//check exist the input if($('#mod-other-mobile-number1').length > 0 && $('#mod-other-mobile-number1').val() != '') { $(this).attr("required", "true"); if ($('#mod-other-mobile-number1').val().length < 10 || !$('#mod-other-mobile-number1').val().startsWith("9")) { addCustomerModalTabSelectedTab(2); alert('error other mobile contact');return; $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val().length > 10) { // $('#mod-other-mobile-number1').val(''); $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val() == $('#mod-contact').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } }else if($('#mod-other-mobile-number1').length ===1 && $('#mod-other-mobile-number1').val()===''){ // console.log('accept validation');return; $("#mod-other-mobile-number1").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-mobile-number2').focus(); return; } else { $("#mod-other-mobile-number1").prop('required',false); } if($('#mod-other-mobile-number2').length > 0 && $('#mod-other-mobile-number2').val() != '') { // console.log('accept validation');return; if($('#mod-other-mobile-number2').val().length < 10 || !$('#mod-other-mobile-number2').val().startsWith("9")) { addCustomerModalTabSelectedTab(2);alert('error other mobile contact'); $('#mod-other-mobile-number2').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val() == $('#mod-other-mobile-number2').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } if($('#mod-other-mobile-number2').val() == $('#mod-contact').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } if($('#mod-other-mobile-number1').val().length > 10) { // $('#mod-other-mobile-number1').val(''); $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } else if($('#mod-other-mobile-number2').length ===1 && $('#mod-other-mobile-number2').val()===''){ // console.log('accept validation');return; $("#mod-other-mobile-number2").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-mobile-number2').focus(); return; } else { // console.log(''+$('#mod-other-mobile-number2').length); $('#mod-other-mobile-number2').attr("required", "false"); $('#mod-other-mobile-number2').removeAttr('required'); } //END MODIFY } else if (parseInt(customer_record_type) === 2) { if(isEmpty($('#mod-contact').val()) && isEmpty($('#mod-landline').val()) ) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Mobile number or landline is required'); return; } if (!isEmpty($('#mod-contact').val())) { if ($('#mod-contact').val().length < 5) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } } // if (!isEmpty($('#mod-email').val())) { // if (!isEmail($('#mod-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Invalid email address'); // return; // } // } // if (!isEmpty($('#mod-other-email').val())) { // if (!isEmail($('#mod-other-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-other-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Invalid other email address'); // return; // } // } //MODIFY if (!isEmpty($('#mod-email').val())) { if (!isEmail($('#mod-email').val())) { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid email address'); return; } } else { $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', 'Email address required'); return; } if($('#mod-other-email1').length > 0 && $('#mod-other-email1').val() != '') { if (!isEmpty($('#mod-other-email1').val())) { if (!isEmail($('#mod-other-email1').val())) { addCustomerModalTabSelectedTab(2); $('#mod-other-email1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid other email address'); return; } } if($('#mod-other-email1').val() == $('#mod-email').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate email address.'); return; } }else if($('#mod-other-email1').length ===1 && $('#mod-other-email1').val()===''){ // console.log('accept validation');return; $("#mod-other-email1").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-email1').focus(); return; }else { $("#mod-other-email1").prop('required',false); // sweetAlertSimple('error', 'Oops...', 'Field required.'); // $('#mod-other-email2').focus(); // return; } if($('#mod-other-email2').length > 0 && $('#mod-other-email2').val() != '') { if (!isEmpty($('#mod-other-email2').val())) { if (!isEmail($('#mod-other-email2').val())) { addCustomerModalTabSelectedTab(2); $('#mod-other-email2').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid other email address'); return; } } if($('#mod-other-email2').val() == $('#mod-email').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate email address.'); return; } if($('#mod-other-email1').val() == $('#mod-other-email2').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate email address.'); return; } } else if($('#mod-other-email2').length ===1 && $('#mod-other-email2').val()===''){ // console.log('accept validation');return; $("#mod-other-email2").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-email1').focus(); return; } else { $("#mod-other-email2").prop('required',false); // sweetAlertSimple('error', 'Oops...', 'Field required.'); // $('#mod-other-email2').focus(); // return; } //END MODIFY var validate_data_contact_person = checkIfContactPersonIncomplete(); if (!validate_data_contact_person[0] && $('#contact-person-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the data of contact person first') return; } else if (!validate_data_contact_person[1]) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Contact person invalid email') return; } else if (!validate_data_contact_person[2]) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Contact person invalid mobile') return; } if (!isEmpty($('#mod-dd-city-2').val())) { if (isEmpty($('#mod-address-2').val())) { addCustomerModalTabSelectedTab(2); $('#mod-address-2').focus(); sweetAlertSimple('error', 'Oops...', 'Enter secondary address'); return; } } var validate_data_children_list = checkIfChildrenIncomplete(); if (!validate_data_children_list[0] && $('#children-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(3); $('#children-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the child details first'); return; } else if (!validate_data_children_list[1]) { addCustomerModalTabSelectedTab(3); $('#children-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Children data invalid mobile'); return; } if (!checkIfInterestIncomplete() && $('#interest-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(5); $('#interest-list-table select').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the interest/hobbies details first'); return; } if (!checkIfAffiliationsIncomplete() && $('#affiliations-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(4); $('#affiliations-list-table select').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the affiliations details first'); return; } $.ajax({ url: "api/customer/customerv2.php", method: "POST", dataType: 'json', data: { apiKey: '8906433219679554', customer_id: customer_record_id, customer_data: getCustomerAllModalData(), customer_dms: getAllDataSourceTableData(), customer_contact_person: getAllContactPersonTableData(), customer_children: getAllChildrenTableData(), customer_interest: getAllInterestTableData(), customer_affiliations: getAllAffiliationsTableData(), force_update : force_update, force_update_reason:force_update_reason }, beforeSend: function() { //show loader $('#proceed-button').attr('disabled', true); $('.customer-modal-overlay').show(); }, success: function(result) { if (parseInt(result.status) === 1) { sweetAlertSimple('success', 'Nice...', result.message); fetchCustomerInfo(customer_record_id); //error city dropdown after call $('#modal-customer').modal('hide'); } else if (parseInt(result.status) === 0) { sweetAlertSimple('error', 'Oops...', result.message); } else if (parseInt(result.status) === 2) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', result.message); if(customer_force_edit){ Swal.fire({ title: 'Update anyway?', input: 'textarea', inputPlaceholder: 'Enter your reason', confirmButtonText: `Save`, showCancelButton: true, inputValidator: (value) => { if (!value) { return 'Enter your reason to proceed.' }else{ force_update = 1; force_update_reason = value; $('#proceed-button').click(); } } }); } } else if (parseInt(result.status) === 3) { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', result.message); if(customer_force_edit){ Swal.fire({ title: 'Update anyway?', input: 'textarea', inputPlaceholder: 'Enter your reason', confirmButtonText: `Save`, showCancelButton: true, inputValidator: (value) => { if (!value) { return 'Enter your reason to proceed.' }else{ force_update = 1; force_update_reason = value; $('#proceed-button').click(); } } }); } } else if (parseInt(result.status) === 4) { addCustomerModalTabSelectedTab(1); $('#data-source-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', result.message); } refreshModalReligion(); $('#proceed-button').attr('disabled', false); $('.customer-modal-overlay').hide(); force_update = 0; force_update_reason = ''; }, error: handleError }); }); $('#customer_delete_action').click(function() { removeCustomer(customer_record_id) }) $('#aha-status').on('change',function(){ if($(this).is(':checked')){ $(this).val('1'); }else{ $(this).val('0'); } }); //MODIFY //add mobile number dynamically $("#btn-add-mobile").on('click', function(){ // var count = $("#countInputMobile").val(); // count++; let inputMobLengh = $('.mod-div input[name="mob[]"]').length; if(inputMobLengh<2){ let divGrid = $('<div></div>').attr({'class':'mod-div'}); let inputGroup = $('<div></div>').attr({'class':'input-group mb-0 input-other-mob'}); let inputBtl = $('<div></div>').attr({'class' : 'edit-customer input-group-append'}).css("height", "28px");; let inputText = $('<div></div>').attr({'class':'input-group-text'}).text("+63"); let inputjson = $('<input>').attr({'name':'mob[]','id':'mod-other-mobile-number','class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm inputMobile', 'id':'mod-other-mobile-number2','type':'number','maxlength':'10','json-modal':'true'}); let label = $('<label></label>').attr({'for': 'Other Mobile','class':'lbl-forms mx-0 my-0'}).text("Other Mobile"); $(inputBtl).append(inputText); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger'}).click(function(e){ // count--; // $("#countInputMobile").prop("value",count); $(this).closest('.mod-div').remove(); inputMobLengh = inputMobLengh-1; if(inputMobLengh<2){ $("#btn-add-mobile").show(); } else { $("#btn-add-mobile").hide(); } $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); }); //end delete $(inputGroup).append(inputBtl,inputjson,deleteSPan); $(divGrid).append(label,inputGroup); $("#mod-contact-div").append(divGrid); $("#countInputMobile").val(count); $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); if(inputMobLengh>=1){ $("#btn-add-mobile").hide(); } else{ $("#btn-add-mobile").show(); } } //end if }); $("#btn-add-email").on('click', function(){ // var count = $("#countInputMobile").val(); // count++; let inputEmailCount =$('#email-add input[name="mob-email[]"]').length; if(inputEmailCount<2){ let divGrid = $('<div></div>').attr({'class':'col-sm-12 mb-1 div-email'}); let inputGroup = $('<div></div>').attr({'class':'form-group mb-0'}); let inputGroup2 = $('<div></div>').attr({'class':'input-group'}); let label = $('<label></label>').attr({'class':'lbl-forms mx-0 my-0'}).text("Other Email"); let inputjson = $('<input>').attr({'name':'mob-email[]','id':'mod-other-email','class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm inputMobile','type':'email','json-modal':'true'}); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger','required':true}).click(function(e){ inputEmailCount = inputEmailCount-1; // $("#countInputMobile").prop("value",count); if(inputEmailCount>=1){ $("#btn-add-email").hide(); } else{ $("#btn-add-email").show(); } // alert('fire') $(this).closest('.div-email').remove(); $('#email-addinput[name="mob-email[]"]').each(function(index){ $(this).attr('id',"mod-other-email"+(index+1)); }); }); //end delete $(inputGroup2).append(inputjson,deleteSPan); $(inputGroup).append(label,inputGroup2); $(divGrid).append(inputGroup); $('#email-add').append(divGrid); if(inputEmailCount>=1){ $("#btn-add-email").hide(); } else{ $("#btn-add-email").show(); } $('#email-add input[name="mob-email[]"]').each(function(index){ $(this).attr('id',"mod-other-email"+(index+1)); }); } //end if }); //END MODIFY });
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings